aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/json/json_query/passing.sql
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-11-20 17:37:57 +0000
committerGitHub <noreply@github.com>2024-11-20 17:37:57 +0000
commitf76323e9b295c15751e51e3443aa47a36bee8023 (patch)
tree4113c8cad473a33e0f746966e0cf087252fa1d7a /yql/essentials/tests/sql/suites/json/json_query/passing.sql
parent753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff)
parenta7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff)
downloadydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yql/essentials/tests/sql/suites/json/json_query/passing.sql')
-rw-r--r--yql/essentials/tests/sql/suites/json/json_query/passing.sql114
1 files changed, 114 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/json/json_query/passing.sql b/yql/essentials/tests/sql/suites/json/json_query/passing.sql
new file mode 100644
index 0000000000..f1b09b1d27
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/json/json_query/passing.sql
@@ -0,0 +1,114 @@
+/* syntax version 1 */
+/* postgres can not */
+
+$json = CAST(@@{
+ "key": 123
+}@@ as Json);
+
+-- Check all supported types for variables
+SELECT
+ -- Numeric types
+ JSON_QUERY(
+ $json,
+ "strict $var1 + $var2 + $var3 + $var4 + $var5 + $var6 + $var7 + $var8 + $var9 + $var10"
+ PASSING
+ CAST(1 as Int8) as var1,
+ CAST(2 as Uint8) as var2,
+ CAST(3 as Int16) as var3,
+ CAST(4 as Uint16) as var4,
+ CAST(5 as Int32) as var5,
+ CAST(6 as Uint32) as var6,
+ CAST(7 as Int64) as var7,
+ CAST(8 as Uint64) as var8,
+ CAST(9 as Double) as var9,
+ CAST(10 as Float) as var10
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ -- Time types
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ CAST(1582044622 as Datetime) as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ CAST(1582044622 as Timestamp) as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ CAST("2020-02-18" as Date) as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ -- Utf8
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ CAST("привет" as Utf8) as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ -- Bool
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ true as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ -- Json
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ $json as var
+ ),
+ -- Nulls
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ Nothing(Int64?) as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ JSON_QUERY(
+ $json,
+ "strict $var"
+ PASSING
+ NULL as var
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ );
+
+-- Check various ways to pass variable name
+SELECT
+ JSON_QUERY(
+ $json, "strict $var1"
+ PASSING
+ 123 as var1
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ -- NOTE: VaR1 is not casted to upper-case VAR1 as standard expects
+ JSON_QUERY(
+ $json, "strict $VaR1"
+ PASSING
+ 123 as VaR1
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ JSON_QUERY(
+ $json, "strict $var1"
+ PASSING
+ 123 as "var1"
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ),
+ JSON_QUERY(
+ $json, "strict $VaR1"
+ PASSING
+ 123 as "VaR1"
+ WITH UNCONDITIONAL ARRAY WRAPPER
+ ); \ No newline at end of file