From d57fde2a95d02fd96d863c676fb309f82a28c316 Mon Sep 17 00:00:00 2001 From: AFine-gs <69924417+AFine-gs@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:41:59 -0500 Subject: [PATCH] update SN reserved words (#2536) --- .../TestSnowflakeExplodeSemiStructured.java | 22 +++++++++---------- .../sqlQueryToString/snowflakeExtension.pure | 7 ------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/semiStructured/TestSnowflakeExplodeSemiStructured.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/semiStructured/TestSnowflakeExplodeSemiStructured.java index 5d1a410d1e6..067d778e714 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/semiStructured/TestSnowflakeExplodeSemiStructured.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-execution/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/test/semiStructured/TestSnowflakeExplodeSemiStructured.java @@ -33,7 +33,7 @@ public void testSimplePrimitivePropertiesProjectExplodeSource() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\"), (Orders/Identifier, String, VARCHAR(100), \"\"), (Orders/Price, Float, DOUBLE, \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"Orders/Id\", VARCHAR(100)), (\"Orders/Identifier\", VARCHAR(100)), (\"Orders/Price\", DOUBLE)]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".\"ACCOUNT\" as \"Account\", \"blocks_1\".ID as \"Orders/Id\", \"blocks_1\".IDENTIFIER as \"Orders/Identifier\", \"blocks_1\".PRICE as \"Orders/Price\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".ACCOUNT as \"Account\", \"blocks_1\".ID as \"Orders/Id\", \"blocks_1\".IDENTIFIER as \"Orders/Identifier\", \"blocks_1\".PRICE as \"Orders/Price\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\"), (Orders/Identifier, String, VARCHAR(100), \"\"), (Orders/Price, Float, DOUBLE, \"\")]\n"; @@ -51,7 +51,7 @@ public void testSimplePrimitivePropertiesProjectExplodeTarget() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Status\", VARCHAR(100)), (\"Block/Id\", VARCHAR(100)), (\"Block/Account\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\", \"trades_1\".ID as \"Block/Id\", \"trades_1\".\"ACCOUNT\" as \"Block/Account\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".\"ACCOUNT\", \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".\"ACCOUNT\", \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\", \"trades_1\".ID as \"Block/Id\", \"trades_1\".ACCOUNT as \"Block/Account\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".ACCOUNT, \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".ACCOUNT, \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\")]\n"; @@ -87,7 +87,7 @@ public void testComplexProjectMultiplePropertiesToExplodeInProject() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\"), (Orders/Identifier, String, VARCHAR(100), \"\"), (Trades/Id, String, VARCHAR(100), \"\"), (Trades/Status, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"Orders/Id\", VARCHAR(100)), (\"Orders/Identifier\", VARCHAR(100)), (\"Trades/Id\", VARCHAR(100)), (\"Trades/Status\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".\"ACCOUNT\" as \"Account\", \"blocks_1\".ID as \"Orders/Id\", \"blocks_1\".IDENTIFIER as \"Orders/Identifier\", \"blocks_3\".ID as \"Trades/Id\", \"blocks_3\".STATUS as \"Trades/Status\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_3\" on (\"root\".ID = \"blocks_3\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".ACCOUNT as \"Account\", \"blocks_1\".ID as \"Orders/Id\", \"blocks_1\".IDENTIFIER as \"Orders/Identifier\", \"blocks_3\".ID as \"Trades/Id\", \"blocks_3\".STATUS as \"Trades/Status\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_3\" on (\"root\".ID = \"blocks_3\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\"), (Orders/Identifier, String, VARCHAR(100), \"\"), (Trades/Id, String, VARCHAR(100), \"\"), (Trades/Status, String, VARCHAR(100), \"\")]\n"; @@ -105,7 +105,7 @@ public void testSimplePrimitivePropertiesProjectWithFilterOnSource() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Trades/Id, String, VARCHAR(100), \"\"), (Trades/Status, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"Trades/Id\", VARCHAR(100)), (\"Trades/Status\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".\"ACCOUNT\" as \"Account\", \"blocks_1\".ID as \"Trades/Id\", \"blocks_1\".STATUS as \"Trades/Status\" from Semistructured.Blocks as \"root\" left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) where (\"root\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"root\".BLOCKDATA['status']::varchar is null)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".ACCOUNT as \"Account\", \"blocks_1\".ID as \"Trades/Id\", \"blocks_1\".STATUS as \"Trades/Status\" from Semistructured.Blocks as \"root\" left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) where (\"root\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"root\".BLOCKDATA['status']::varchar is null)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Trades/Id, String, VARCHAR(100), \"\"), (Trades/Status, String, VARCHAR(100), \"\")]\n"; @@ -123,7 +123,7 @@ public void testSimplePrimitivePropertiesProjectWithFilterOnTarget() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Status\", VARCHAR(100)), (\"Block/Id\", VARCHAR(100)), (\"Block/Account\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\", \"trades_1\".ID as \"Block/Id\", \"trades_1\".\"ACCOUNT\" as \"Block/Account\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".\"ACCOUNT\", \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".\"ACCOUNT\", \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0) where (\"trades_1\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"trades_1\".BLOCKDATA['status']::varchar is null)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\", \"trades_1\".ID as \"Block/Id\", \"trades_1\".ACCOUNT as \"Block/Account\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".ACCOUNT, \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".ACCOUNT, \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0) where (\"trades_1\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"trades_1\".BLOCKDATA['status']::varchar is null)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\")]\n"; @@ -141,7 +141,7 @@ public void testProjectWithExplodedPropertyAccessOnlyInFilter() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Status\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".\"ACCOUNT\", \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".\"ACCOUNT\", \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0) where (\"trades_1\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"trades_1\".BLOCKDATA['status']::varchar is null)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".STATUS as \"Status\" from Semistructured.Trades as \"root\" left outer join (select \"trades_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".ACCOUNT, \"blocks_0\".BLOCKDATA from Semistructured.Trades as \"trades_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".ACCOUNT, \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_2\".ID)) as \"trades_1\" on (\"root\".ID = \"trades_1\".leftJoinKey_0) where (\"trades_1\".BLOCKDATA['status']::varchar <> 'cancelled' OR \"trades_1\".BLOCKDATA['status']::varchar is null)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Status, String, VARCHAR(100), \"\")]\n"; @@ -159,7 +159,7 @@ public void testFilterOnExplodedPropertyFilteringInsideProject() " (\n" + " type = TDS[(Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\"), (Big Buy Orders, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Block/Id\", VARCHAR(100)), (\"Block/Account\", VARCHAR(100)), (\"Big Buy Orders\", VARCHAR(100)), (\"Orders/Id\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Block/Id\", \"root\".\"ACCOUNT\" as \"Block/Account\", \"blocks_1\".ID as \"Big Buy Orders\", \"blocks_3\".ID as \"Orders/Id\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0 and (\"blocks_1\".QUANTITY >= 100 and \"blocks_1\".SIDE = 'BUY')) left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_3\" on (\"root\".ID = \"blocks_3\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Block/Id\", \"root\".ACCOUNT as \"Block/Account\", \"blocks_1\".ID as \"Big Buy Orders\", \"blocks_3\".ID as \"Orders/Id\" from Semistructured.Blocks as \"root\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0 and (\"blocks_1\".QUANTITY >= 100 and \"blocks_1\".SIDE = 'BUY')) left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_3\" on (\"root\".ID = \"blocks_3\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Block/Id, String, VARCHAR(100), \"\"), (Block/Account, String, VARCHAR(100), \"\"), (Big Buy Orders, String, VARCHAR(100), \"\"), (Orders/Id, String, VARCHAR(100), \"\")]\n"; @@ -177,7 +177,7 @@ public void testAggregationAggregateExplodedPropertyUsingGroupBy() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (quantity, Integer, INT, \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"quantity\", \"\")]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".\"ACCOUNT\" as \"Account\", sum(\"blocks_1\".TRADESUMMARY['execQuantity']) as \"quantity\" from Semistructured.Blocks as \"root\" left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) group by \"Id\",\"Account\"\n" + + " sql = select \"root\".ID as \"Id\", \"root\".ACCOUNT as \"Account\", sum(\"blocks_1\".TRADESUMMARY['execQuantity']) as \"quantity\" from Semistructured.Blocks as \"root\" left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_2\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_2\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_2\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_2\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".leftJoinKey_0) group by \"Id\",\"Account\"\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (quantity, Integer, INT, \"\")]\n"; @@ -195,7 +195,7 @@ public void testAggregationAggregateExplodedPropertyInsideProject() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Buy Order, Integer, \"\", \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"Buy Order\", INT)]\n" + - " sql = select \"root\".ID as \"Id\", \"root\".\"ACCOUNT\" as \"Account\", \"blocks_1\".aggCol as \"Buy Order\" from Semistructured.Blocks as \"root\" left outer join (select \"blocks_2\".ID as ID, sum(\"blocks_3\".QUANTITY) as aggCol from Semistructured.Blocks as \"blocks_2\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_4\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_4\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_4\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_4\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_3\" on (\"blocks_2\".ID = \"blocks_3\".leftJoinKey_0) where \"blocks_3\".SIDE = 'BUY' group by \"blocks_2\".ID) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".ID)\n" + + " sql = select \"root\".ID as \"Id\", \"root\".ACCOUNT as \"Account\", \"blocks_1\".aggCol as \"Buy Order\" from Semistructured.Blocks as \"root\" left outer join (select \"blocks_2\".ID as ID, sum(\"blocks_3\".QUANTITY) as aggCol from Semistructured.Blocks as \"blocks_2\" left outer join (select \"orders_0\".ID, \"orders_0\".IDENTIFIER, \"orders_0\".QUANTITY, \"orders_0\".SIDE, \"orders_0\".PRICE, \"blocks_4\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_4\" inner join Semistructured.Orders as \"orders_0\" on (to_varchar(get_path(\"blocks_4\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_4\".flattened_prop, 'tagId')) = \"orders_0\".ID)) as \"blocks_3\" on (\"blocks_2\".ID = \"blocks_3\".leftJoinKey_0) where \"blocks_3\".SIDE = 'BUY' group by \"blocks_2\".ID) as \"blocks_1\" on (\"root\".ID = \"blocks_1\".ID)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Buy Order, Integer, \"\", \"\")]\n"; @@ -213,7 +213,7 @@ public void testSimpleJoinChainOneJoin() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Account\", VARCHAR(100)), (\"Block/Id\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"orders_1\".\"ACCOUNT\" as \"Account\", \"orders_1\".ID as \"Block/Id\" from Semistructured.Orders as \"root\" left outer join (select \"orders_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".\"ACCOUNT\", \"blocks_0\".BLOCKDATA from Semistructured.Orders as \"orders_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".\"ACCOUNT\", \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"orders_2\".ID)) as \"orders_1\" on (\"root\".ID = \"orders_1\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Id\", \"orders_1\".ACCOUNT as \"Account\", \"orders_1\".ID as \"Block/Id\" from Semistructured.Orders as \"root\" left outer join (select \"orders_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".ACCOUNT, \"blocks_0\".BLOCKDATA from Semistructured.Orders as \"orders_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".ACCOUNT, \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"orders_2\".ID)) as \"orders_1\" on (\"root\".ID = \"orders_1\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Account, String, VARCHAR(100), \"\"), (Block/Id, String, VARCHAR(100), \"\")]\n"; @@ -249,7 +249,7 @@ public void testJoinChainMultipleJoinsMultipleExplode() " (\n" + " type = TDS[(Id, String, VARCHAR(100), \"\"), (Trade Id, String, VARCHAR(100), \"\")]\n" + " resultColumns = [(\"Id\", VARCHAR(100)), (\"Trade Id\", VARCHAR(100))]\n" + - " sql = select \"root\".ID as \"Id\", \"blocks_2\".ID as \"Trade Id\" from Semistructured.Orders as \"root\" left outer join (select \"orders_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".\"ACCOUNT\", \"blocks_0\".BLOCKDATA from Semistructured.Orders as \"orders_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".\"ACCOUNT\", \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"orders_2\".ID)) as \"orders_1\" on (\"root\".ID = \"orders_1\".leftJoinKey_0) left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_0\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_2\" on (\"orders_1\".ID = \"blocks_2\".leftJoinKey_0)\n" + + " sql = select \"root\".ID as \"Id\", \"blocks_2\".ID as \"Trade Id\" from Semistructured.Orders as \"root\" left outer join (select \"orders_2\".ID as leftJoinKey_0, \"blocks_0\".ID, \"blocks_0\".ACCOUNT, \"blocks_0\".BLOCKDATA from Semistructured.Orders as \"orders_2\" inner join (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID, \"root\".ACCOUNT, \"root\".BLOCKDATA from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'order' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"orders_2\".ID)) as \"orders_1\" on (\"root\".ID = \"orders_1\".leftJoinKey_0) left outer join (select \"trades_0\".ID, \"trades_0\".STATUS, \"trades_0\".TRADESUMMARY, \"blocks_0\".leftJoinKey_0 as leftJoinKey_0 from (select \"ss_flatten_0\".value as flattened_prop, \"root\".ID as leftJoinKey_0 from Semistructured.Blocks as \"root\" inner join lateral flatten(input => \"root\".BLOCKDATA['relatedEntities'], outer => true, recursive => false, mode => 'array') as \"ss_flatten_0\") as \"blocks_0\" inner join Semistructured.Trades as \"trades_0\" on (to_varchar(get_path(\"blocks_0\".flattened_prop, 'tag')) = 'trade' and to_varchar(get_path(\"blocks_0\".flattened_prop, 'tagId')) = \"trades_0\".ID)) as \"blocks_2\" on (\"orders_1\".ID = \"blocks_2\".leftJoinKey_0)\n" + " connection = RelationalDatabaseConnection(type = \"Snowflake\")\n" + " )\n"; String TDSType = " type = TDS[(Id, String, VARCHAR(100), \"\"), (Trade Id, String, VARCHAR(100), \"\")]\n"; diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure index f36a6cb8a3d..febd1ca1d93 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-snowflake/legend-engine-xt-relationalStore-snowflake-pure/src/main/resources/core_relational_snowflake/relational/sqlQueryToString/snowflakeExtension.pure @@ -368,7 +368,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf { // Based on https://docs.snowflake.com/en/sql-reference/reserved-keywords [ - 'account', 'alter', 'and', 'any', @@ -380,7 +379,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'check', 'column', 'connect', - 'connection', 'constraint', 'create', 'cross', @@ -402,7 +400,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'full', 'grant', 'group', - 'gscluster', 'having', 'ilike', 'in', @@ -412,7 +409,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'intersect', 'into', 'is', - 'issue', 'join', 'lateral', 'left', @@ -427,7 +423,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'on', 'or', 'order', - 'organization', 'qualify', 'regexp', 'revoke', @@ -436,7 +431,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'row', 'rows', 'sample', - 'schema', 'select', 'set', 'some', @@ -453,7 +447,6 @@ function <> meta::relational::functions::sqlQueryToString::snowf 'update', 'using', 'values', - 'view', 'when', 'whenever', 'where',