2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

謎のスプレッド演算子 ** が進化していた!(その名はExpansion operators)

Posted at

2025年3月に発見された、Snowflakeの演算子 ** が、いつの間にかテーブルの検索結果にも使えるようになっていたのでお知らせします。

発見当初は↓みたいな感じで使えて、カラムには対応していませんでした。

select 1 in (**[1, 2, 3, 4]);

↓これはエラーだった。

SELECT ** col1
FROM hoge_table;

先ほどドキュメントが更新されてたので確認したところ、サンプルがありました。

> SELECT * FROM spread_demo;

+------+------+
| COL1 | COL2 |
|------+------|
|    1 | a    |
|    2 | b    |
|    3 | c    |
|    4 | d    |
|    5 | e    |
+------+------+

> SELECT * FROM spread_demo
  WHERE col1 IN (** [3, 4])
  ORDER BY col1;

+------+------+
| COL1 | COL2 |
|------+------|
|    3 | c    |
|    4 | d    |
+------+------+

あれ、思ってたのと使い方違う。
前回エラーだったやつを投げてみると、やっぱりエラー。

> select **col1
FROM spread_demo;

000002 (0A000): Unsupported feature 'spread argument with non-constant array input'.

ドキュメントの最初に書いてあるのですが、
・IN句
・システム定義関数の呼び出し
・UDF
・バインド変数を使用するストアドプロシージャ
とかを想定しているようです。
カラムにArrayを入れて、それをどうにかする系ではなかったです。

また進化していたらお知らせします。ではまた。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?