クエリの設定
データソースを設定した後、クエリを設定してSQL Transformationsを続行します。
クエリの設定
データソースを指定した後、データに対して動作するクエリを定義できます。 SQL TransformationsはApache DataFusionクエリエンジンを基盤としており、すべての標準SQL操作をサポートしています。
次のフィールドを設定します。
| フィールド | 説明 |
|---|---|
| クエリパラメーター | クエリのWHERE条件で使用するパラメーターを追加します。 例: id。 各パラメーターに値を割り当てます。値には静的な値またはデータピルを指定できます。 バインド変数に対してデータベースが想定するデータ型に最も近い対応するデータ型を選択します。 |
| SQLクエリ | 1つ以上のデータソースをクエリするSQL select文を追加します。 結合と複雑な関数がサポートされています。 バインド変数表記を使用して、WHERE条件にパラメーターを追加します。例: id = @id。ここで、idはクエリパラメーターセクションのフィールド名です。 |
| エンジン | クエリを実行するApache DataFusionエンジンのバージョンを選択します。 デフォルトはDataFusion v53です。 既存のクエリで以前のエンジンバージョンが必要な場合は、DataFusion v42を選択します。 v53での変更の詳細については、Apache DataFusion 53.0.0リリースノートを参照してください。 |
クエリ設定の例
次のクエリは、両方のテーブルのzipcode列に基づいて、employeeテーブルとzipcodeテーブルを結合します。
クエリ設定の例
大文字と小文字
前述の例では、すべてのCSVヘッダーが小文字です。 クエリに大文字を含むCSVヘッダーが含まれる場合、大文字を含むヘッダーを引用符("")で囲む必要があります。 例:
sql
SELECT distinct test."PropertyId", test."Tract_Business" FROM test ORDER by test."PropertyId" LIMIT 1 OFFSET 2サポートされている操作
次のセクションには、SQL Transformationsでサポートされているデータ型、構文句、サブクエリ、関数、およびサポートされていないデータ型のリストが含まれます。
データ型
文字型
- CHAR
- VARCHAR
- TEXT
- STRING
数値型
- TINYINT
- SMALLINT
- INT or INTEGER
- BIGINT
- TINYINT UNSIGNED
- SMALLINT UNSIGNED
- INT UNSIGNED or INTEGER UNSIGNED
- BIGINT UNSIGNED
- FLOAT
- REAL
- DOUBLE
- DECIMAL(precision, scale)
日付/時刻型
- DATE
- TIME
- TIMESTAMP
- INTERVAL
ブール型
- BOOLEAN
バイナリ型
- BYTEA
Arrow型
- Null
- ブール値
- Int8
- Int16
- Int32
- Int64
- UInt8
- UInt16
- UInt32
- UInt64
- Float16
- Float32
- Float64
- Utf8
- LargeUtf8
- Binary
- Timestamp(Second, None)
- Timestamp(Millisecond, None)
- Timestamp(Microsecond, None)
- Timestamp(Nanosecond, None)
- Time32
- Time64
- Duration(Second)
- Duration(Millisecond)
- Duration(Microsecond)
- Duration(Nanosecond)
- Interval(YearMonth)
- Interval(DayTime)
- Interval(MonthDayNano)
- FixedSizeBinary(<len>)
- 例: FixedSizeBinary(16)
- Decimal128(<precision>, <scale>)
- 例: Decimal128(3, 10)
- Decimal256(<precision>, <scale>)
- 例: Decimal256(3, 10)
サポートされていないデータ型
サポートされていない型
- UUID
- BLOB
- CLOB
- BINARY
- VARBINARY
- REGCLASS
- NVARCHAR
- CUSTOM
- ARRAY
- ENUM
- SET
- DATETIME
SELECT構文句
サポートされているSELECT構文句
- WITH
- SELECT
- FROM
- WHERE
- JOIN
- INNER JOIN
- LEFT OUTER JOIN
- RIGHT OUTER JOIN
- FULL OUTER JOIN
- NATURAL JOIN
- CROSS JOIN
- GROUP BY
- HAVING
- UNION
- ORDER BY
- LIMIT
- EXCLUDE and EXCEPT
サブクエリ
サポートされているSELECTサブクエリ
- EXISTS
- NOT EXISTS
- IN
- NOT IN
- スカラーサブクエリ
演算子
数値演算子
+(加算)-(減算)*(乗算)/(除算)%(剰余)
比較演算子
=(等しい)!=(等しくない)<(より小さい)<=(以下)>(より大きい)>=(以上)- IS DISTINCT FROM
- IS NOT DISTINCT FROM
~(正規表現一致)~*(正規表現の大文字小文字を区別しない一致)!~(正規表現不一致)!~*(正規表現の大文字小文字を区別しない不一致)
論理演算子
- AND
- OR
ビット単位演算子
&(ビット単位AND)|(ビット単位OR)#(ビット単位XOR)>>(ビット単位右シフト)<<(ビット単位左シフト)
その他の演算子
||(文字列連結)@>(配列が含む)<@(配列が含まれる)
集計関数
一般
- avg
- bit_and
- bit_or
- bit_xor
- bool_and
- bool_or
- count
- max
- mean
- median
- min
- sum
- array_agg
- first_value
- last_value
統計
- corr
- covar
- covar_pop
- covar_samp
- stddev
- stddev_pop
- stddev_samp
- var
- var_pop
- var_samp
- regr_avgx
- regr_avgy
- regr_count
- regr_intercept
- regr_r2
- regr_slope
- regr_sxx
- regr_syy
- regr_sxy
近似
- approx_distinct
- approx_median
- approx_percentile_cont
- approx_percentile_cont_with_weight
ウィンドウ関数
集計関数
すべての集計関数は、ウィンドウ関数として使用できます。
ランキング関数
- row_number
- rank
- dense_rank
- ntile
分析関数
- cume_dist
- percent_rank
- lag
- lead
- first_value
- last_value
- nth_value
スカラー関数
数学関数
- abs(x)
- acos(x)
- acosh(x)
- asin(x)
- asinh(x)
- atan(x)
- atanh(x)
- atan2(y, x)
- cbrt(x)
- ceil(x)
- cos(x)
- cosh(x)
- degrees(x)
- exp(x)
- factorial(x)
- floor(x)
- gcd(x, y)
- isnan(x)
- iszero(x)
- lcm(x, y)
- ln(x)
- log(base, x)
- log10(x)
- log2(x)
- nanvl(x, y)
- pi()
- power(base, exponent)
- pow(base, exponent)
- radians(x)
- random()
- round(x[, decimal_places])
- signum(x)
- sin(x)
- sinh(x)
- sqrt(x)
- tan(x)
- tanh(x)
- trunc(x[, decimal_places])
条件関数
- coalesce
- nullif
- nvl
- nvl2
- ifnull
文字列関数
- ascii
- bit_length
- btrim
- char_length
- character_length
- concat
- concat_ws
- chr
- ends_with
- initcap
- instr
- left
- length
- lower
- lpad
- ltrim
- octet_length
- repeat
- replace
- reverse
- right
- rpad
- rtrim
- split_part
- starts_with
- strpos
- substr
- to_hex
- translate
- trim
- upper
- uuid
- overlay
- levenshtein
- substr_index
- find_in_set
- position
- contains
バイナリ文字列関数
- decode
- encode
正規表現関数
- regexp_like
- regexp_match
- regexp_replace
時間関数
- now
- current_date
- current_time
- date_bin
- date_trunc
- datetrunc
- date_part
- datepart
- extract
- today
- make_date
- to_char(expression, format)
- 例: to_char("Date", "%Y-%m-%d")
- to_date
- to_local_time
- to_timestamp
- to_timestamp_millis
- to_timestamp_micros
- to_timestamp_nanos
- to_timestamp_seconds
- from_unixtime
配列関数
- array_append
- array_sort
- array_cat
- array_concat
- array_contains
- array_dims
- array_distinct
- array_has
- array_has_all
- array_has_any
- array_element
- array_empty
- array_except
- array_extract
- array_fill
- array_indexof
- array_intersect
- array_join
- array_length
- array_ndims
- array_prepend
- array_pop_front
- array_pop_back
- array_position
- array_positions
- array_push_back
- array_push_front
- array_repeat
- array_resize
- array_remove
- array_remove_n
- array_remove_all
- array_replace
- array_replace_n
- array_replace_all
- array_reverse
- array_slice
- array_to_string
- array_union
- cardinality
- empty
- flatten
- generate_series
- list_append
- list_sort
- list_cat
- list_concat
- list_dims
- list_distinct
- list_element
- list_except
- list_extract
- list_has
- list_has_all
- list_has_any
- list_indexof
- list_intersect
- list_join
- list_length
- list_ndims
- list_prepend
- list_pop_back
- list_pop_front
- list_position
- list_positions
- list_push_back
- list_push_front
- list_repeat
- list_resize
- list_remove
- list_remove_n
- list_remove_all
- list_replace
- list_replace_n
- list_replace_all
- list_slice
- list_to_string
- list_union
- make_array
- make_list
- string_to_array
- string_to_list
- trim_array
- unnest
- range
構造体関数
- struct
- named_struct
- unnest
ハッシュ関数
- digest
- md5
- sha224
- sha256
- sha384
- sha512
その他の関数
- arrow_cast
- arrow_typeof
次に読む
サンプルユースケース
次のユースケースでSQL Transformationsを活用する方法については、ステップバイステップの手順を示したガイドを参照してください。
Last updated: