Window Top-N クエリは、ウィンドウテーブル値関数(TVF)と Top-N クエリの変更ルールに従う必要があるため、互換性のある変更が少ないです。このトピックでは、ジョブの Window Top-N クエリを変更した後に、ジョブとジョブの開始に使用される状態データ間の互換性について説明します。
互換性のある変更
完全な互換性:ウィンドウ属性フィールドを追加または削除します。
-- 元の SQL ステートメント: select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3; -- 完全な互換性:クエリ結果に window_end フィールドを追加します。 select a, b, c, window_start, window_end from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3;
完全な互換性:ランキング位置を指定するフィールドをクエリ結果に含めるか除外します。
-- 元の SQL ステートメント: select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3; -- 完全な互換性:クエリ結果に rk フィールドを含めます。 select a, b, c, window_start, rk from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3;
完全な互換性:パーティションキーの順序を変更します。
-- 元の SQL ステートメント: select a, b, c, window_start from ( select *, row_number() over (partition by a, b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, b, window_start, window_end) ) where rk < 3; -- 完全な互換性:パーティションキーの順序を変更します。 select a, b, c, window_start from ( select *, row_number() over (partition by b, a, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, b, window_start, window_end) ) where rk < 3;
互換性のない変更
ウィンドウタイプ、ウィンドウサイズ、時間属性などのウィンドウ関連の属性を変更します。
変更例については、完全な非互換性を引き起こす変更をご参照ください。
group by 句のフィールドを追加、削除、または変更するか、これらのフィールドの計算ロジックを変更します。
変更例については、完全な非互換性を引き起こす変更をご参照ください。
集計フィールドを追加、削除、または変更するか、TOP-N クエリの入力を変更します。
-- 元の SQL ステートメント: select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3; -- 非互換:集計フィールドである min(d) as d を追加します。 -- この変更により、TOP-N クエリの入力が変更されます。 select a, b, c, d, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, min(d) as d, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, window_start, window_end) ) where rk < 3;
パーティションキーを追加、削除、または変更するか、パーティションキーに含まれるフィールドの計算ロジックを変更します。
変更例については、互換性のない変更をご参照ください。
order by 句に指定されたフィールドまたは順序を変更します。
変更例については、互換性のない変更をご参照ください。
N の値を変更します。Top-N クエリでは、N は返す上位ランク結果の数を指定します。
変更例については、互換性のない変更をご参照ください。
group by 句のウィンドウ TVF 関連フィールドの順序のみ、または group by 句の他のフィールドの順序のみを変更します。
-- 元の SQL ステートメント: select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, b, window_start, window_end) ) where rk < 3; -- 非互換:group by 句のウィンドウ TVF 関連フィールドの順序のみを変更します。 -- この変更により、ウィンドウベースのランキング結果が変更されます。 select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by a, b, window_end, window_start) ) where rk < 3; -- 非互換:group by 句の他のフィールドの順序のみを変更します。 select a, b, c, window_start from ( select *, row_number() over (partition by b, window_start, window_end order by c) as rk from ( select a, sum(b) as b, max(c) as c, window_start, window_end from table (tumble(table MyTable, descriptor(ts), interval '1' minute)) group by b, a, window_start, window_end) ) where rk < 3;