[アップデート] Amazon Aurora PostgreSQL 17.5 がリリースされたので、Babelfish 5.2 のアップデート内容を確認してみた

[アップデート] Amazon Aurora PostgreSQL 17.5 がリリースされたので、Babelfish 5.2 のアップデート内容を確認してみた

Clock Icon2025.07.06

いわさです。

先日 Aurora PostgreSQL 17.5 がリリースされました。

https://aws.amazon.com/about-aws/whats-new/2025/07/amazon-aurora-supports-postgresql-versions/

C7B62A59-741C-459A-A7FC-98EC49D3DC44_1_105_c.jpeg

PostgreSQL 17.5 がサポートされたという点以外にも Aurora 固有の様々な機能がアップデートされていますね。[1]
新機能の目玉的なところだと、大きくは以下のふたつがありそうです。

  • Aurora Serverless V2 のスケーリング周りが改善
  • ストレージ容量が 128 TiB から 256 TiB に増えている。より大規模なワークロードで採用しやすくなった

Aurora PostgreSQL の新しいバージョンがリリースされたということは Bebelfish バージョンも更新されているということです。
Bebelfish というのは Aurora PostgreSQL の拡張機能で、SQL Server 互換のインターフェースを提供することで Microsoft SQL Server 対応のクライアントを Aurora PostgreSQL に接続して使うことが出来るようにさせるものです。

https://dev.classmethod.jp/articles/aurora-postgresql-16-8-babelfish-4-5/

完全互換ではないので、必ずしもそのまま移行できるわけではないですが、うまくいけば SQL Server のライセンスコストなどでお悩みの方は Aurora に移行して色々な恩恵を受けることが出来ます。

毎度新バージョンがリリースされるごとに互換性がどんどん向上しているのですが、今回も新しい機能を確認してみましょう。

バージョン確認

まずは Bebelfish のバージョン確認から行います。ここはpsqlから確認します。

% psql -h hoge0703psql.cluster-cpnu9ipu74g4.ap-northeast-1.rds.amazonaws.com -U postgres -d babelfish_db
Password for user postgres: 
psql (14.15 (Homebrew), server 17.5)
WARNING: psql major version 14, server major version 17.
         Some psql features might not work.
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

babelfish_db=> SELECT aurora_version() AS aurora_version, version() AS postgresql_version, sys.version() AS Babelfish_compatibility, sys.SERVERPROPERTY('BabelfishVersion') AS Babelfish_Version;
 aurora_version |                                        postgresql_version                                        |                           babelfish_compatibility                           | babelfish_version 
----------------+--------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------+-------------------
 17.5.1         | PostgreSQL 17.5 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (GCC) 10.5.0, 64-bit | Babelfish for Aurora PostgreSQL with SQL Server Compatibility - 12.0.2000.8+| 5.2.0
                |                                                                                                  | Jun 17 2025 18:12:46                                                       +| 
                |                                                                                                  | Copyright (c) Amazon Web Services                                          +| 
                |                                                                                                  | PostgreSQL 17.5 on x86_64-pc-linux-gnu (Babelfish 5.2.0)                    | 
(1 row)

(END)

Babelfish バージョンは 5.2.0 ですね。

新機能を確認

では Babelfish 5.2.0 で新しく使えるようになった機能を確認してみましょう。
Babelfish のリリースノートは以下です。ここを見るとバージョンごとにどういう機能が追加されるようになったのか確認できます。

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraPostgreSQLReleaseNotes/AuroraBabelfish.Updates.html#AuroraBabelfish.Updates.52X

今回も色々追加や改善されていますが、UNPIVOT がサポートされるようになったみたいですね。というか今までサポートされてなかったのか。
今回改めて調べてみたのですが、これまで PIVOT はサポートされていたのですが、UNPIVOT はサポートされていなかったみたいですね。旧バージョンで試してみたところ次のエラーメッセージが。なるほど。

Msg 33557097, Level 16, State 1, Server hoge0703psql2-instance-1, Line 1
'UNPIVOT' is not currently supported in Babelfish

UNPIVOT は基本的に PIVOT 演算子の逆で、列を行に変換することが出来る機能です。特にデータ分析などの時に縦持ち・横持ちを切り替えたい時によく使うと思います。

https://learn.microsoft.com/ja-jp/sql/t-sql/queries/from-using-pivot-and-unpivot?view=sql-server-ver16

sqlcmdで接続し、サンプルデータを作成します。

% sqlcmd -S hoge0703psql.cluster-cpnu9ipu74g4.ap-northeast-1.rds.amazonaws.com -U postgres -N -C
Password: 
1> CREATE TABLE pvt (VendorID INT,Emp1 INT, Emp2 INT, Emp3 INT, Emp4 INT, Emp5 INT);
2> go
1> INSERT INTO pvt VALUES (1, 4, 3, 5, 4, 4);
2> INSERT INTO pvt VALUES (2, 4, 1, 5, 5, 5);
3> INSERT INTO pvt VALUES (3, 4, 3, 5, 4, 4);
4> INSERT INTO pvt VALUES (4, 4, 2, 5, 5, 4);
5> INSERT INTO pvt VALUES (5, 5, 1, 5, 5, 5);
6> go

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)
1> select * from pvt;
2> go
VendorID    Emp1        Emp2        Emp3        Emp4        Emp5       
----------- ----------- ----------- ----------- ----------- -----------
          1           4           3           5           4           4
          2           4           1           5           5           5
          3           4           3           5           4           4
          4           4           2           5           5           4
          5           5           1           5           5           5

(5 rows affected)

上記データに UNPIVOT を使ってみました。

1> SELECT VendorID, Employee, Orders
2> FROM (
3>     SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5
4>     FROM pvt
5> ) p
6> UNPIVOT
7> (
8>     Orders FOR Employee IN (Emp1, Emp2, Emp3, Emp4, Emp5)
9> ) AS unpvt;
10> go
VendorID    Employee Orders     
----------- -------- -----------
          1 emp1               4
          1 emp2               3
          1 emp3               5
          1 emp4               4
          1 emp5               4
          2 emp1               4
          2 emp2               1
          2 emp3               5
          2 emp4               5
          2 emp5               5
          3 emp1               4
          3 emp2               3
          3 emp3               5
          3 emp4               4
          3 emp5               4
          4 emp1               4
          4 emp2               2
          4 emp3               5
          4 emp4               5
          4 emp5               4
          5 emp1               5
          5 emp2               1
          5 emp3               5
          5 emp4               5
          5 emp5               5

(25 rows affected)

5.1.0 までは UNPIVOT 使用時に Babelfish でサポートされていない旨のエラーが表示されていましたが、5.2.0 では期待どおり処理されるようになりましたね。

Babelfish Commpass も 5.2.0 をサポート

SQL Server データベースアプリケーションを Babelfish へ切り替える際には、まず互換性を評価し、もしサポートされていない機能が含まれている場合は代替手段を検討する必要があります。
この互換性評価にはオープンソースツールである「Babelfish Compass」を使うことが出来ます。

https://github.com/babelfish-for-postgresql/babelfish_compass/releases

Babelfish Compass も Babelfish バージョンを意識する必要がありまして、今回の Babelfish バージョンアップデートと併せて Babelfish Compass もアップデートされています。ありがたい。

さいごに

本日は Amazon Aurora PostgreSQL 17.5 がリリースされたので、Babelfish 5.2 のアップデート内容を確認してみました。

UNPIVOT以外にも、CREATE OR ALTER VIEWがサポートされたり、SSMS でのスクリプトログインがサポートされていたりします。
Babelfish 検討中の方はぜひ新しいバージョンの互換性を確認してみてください。

脚注
  1. Amazon Aurora PostgreSQL updates - Amazon Aurora ↩︎

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.