use of com.linkedin.coral.hive.hive2rel.HiveToRelConverter in project coral by linkedin.
the class TestUtils method initializeViews.
/**
* Initializes the tables used in Coral-Pig unit tests
* @throws HiveException
* @throws MetaException
*/
public static void initializeViews(HiveConf conf) throws HiveException, MetaException, IOException {
String testDir = conf.get(CORAL_PIG_TEST_DIR);
System.out.println("Test Workspace: " + testDir);
FileUtils.deleteDirectory(new File(testDir));
SessionState.start(conf);
Driver driver = new Driver(conf);
HiveMetastoreClient hiveMetastoreClient = new HiveMscAdapter(Hive.get(conf).getMSC());
hiveToRelConverter = new HiveToRelConverter(hiveMetastoreClient);
// Views and tables used in unit tests
run(driver, String.join("\n", "", "CREATE DATABASE IF NOT EXISTS pig"));
run(driver, String.join("\n", "", "CREATE DATABASE IF NOT EXISTS functions"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tableA(a int, b int, c int)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tableB(a int, b int)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tableLeft(a int, b int, c int)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tableRight(d int, e int)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tablestruct(a int, b struct<b0:int>, c struct<c0:struct<c00:int>>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tablemap(m1 map<string,int>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tablecast(i int, bi bigint, fl float, do double, str string, boo boolean)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS pig.tablenull(nullablefield string, field string)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS functions.tablefields(i_1 int, i0 int, i1 int, i2 int, i3 int, fl1 double, fl2 double, fl3 double, str string, substr string, exstr string, bootrue boolean, boofalse boolean, bin binary)"));
}
use of com.linkedin.coral.hive.hive2rel.HiveToRelConverter in project coral by linkedin.
the class HiveToTrinoConverter method create.
public static HiveToTrinoConverter create(HiveMetastoreClient mscClient, Map<String, Boolean> configs) {
checkNotNull(mscClient);
checkNotNull(configs);
HiveToRelConverter hiveToRelConverter = new HiveToRelConverter(mscClient);
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter(configs);
return new HiveToTrinoConverter(hiveToRelConverter, relToTrinoConverter);
}
use of com.linkedin.coral.hive.hive2rel.HiveToRelConverter in project coral by linkedin.
the class TestUtils method initializeViews.
public static void initializeViews(HiveConf conf) throws HiveException, MetaException, IOException {
String testDir = conf.get(CORAL_SPARK_TEST_DIR);
System.out.println("Test Workspace: " + testDir);
FileUtils.deleteDirectory(new File(testDir));
SessionState.start(conf);
Driver driver = new Driver(conf);
HiveMetastoreClient hiveMetastoreClient = new HiveMscAdapter(Hive.get(conf).getMSC());
hiveToRelConverter = new HiveToRelConverter(hiveMetastoreClient);
run(driver, "CREATE TABLE IF NOT EXISTS foo(a int, b varchar(30), c double)");
run(driver, "CREATE TABLE IF NOT EXISTS bar(x int, y double)");
run(driver, "CREATE TABLE IF NOT EXISTS complex(a int, b string, c array<double>, s struct<name:string, age:int>, m map<int, string>, sarr array<struct<name:string, age:int>>)");
run(driver, "CREATE FUNCTION default_foo_dali_udf_LessThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF'");
run(driver, "CREATE FUNCTION default_foo_dali_udf2_GreaterThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF2'");
run(driver, "CREATE FUNCTION default_foo_dali_udf3_GreaterThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF2'");
run(driver, "CREATE FUNCTION default_foo_dali_udf3_FuncSquare as 'com.linkedin.coral.hive.hive2rel.CoralTestUdfSquare'");
run(driver, "CREATE FUNCTION default_foo_dali_udf4_GreaterThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF2'");
run(driver, "CREATE FUNCTION default_foo_dali_udf5_UnsupportedUDF as 'com.linkedin.coral.hive.hive2rel.CoralTestUnsupportedUDF'");
run(driver, "create function default_foo_lateral_udtf_CountOfRow as 'com.linkedin.coral.hive.hive2rel.CoralTestUDTF'");
run(driver, "create function default_foo_duplicate_udf_LessThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF'");
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_view", "AS", "SELECT b AS bcol, sum(c) AS sum_c", "FROM foo", "GROUP BY b"));
run(driver, "DROP VIEW IF EXISTS foo_v1");
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_v1 ", "AS ", "SELECT DATE '2013-01-01', '2017-08-22 01:02:03', CAST(123 AS SMALLINT), CAST(123 AS TINYINT) ", "FROM foo", "LIMIT 1"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_bar_view", "AS", "SELECT foo_view.bcol, bar.x", "FROM foo_view JOIN bar", "ON bar.y = foo_view.sum_c"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_dali_udf", "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF',", " 'dependencies' = 'ivy://com.linkedin:udf:1.0')", "AS", "SELECT default_foo_dali_udf_LessThanHundred(a)", "FROM foo"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_dali_udf2", "tblproperties('functions' = 'GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2',", " 'dependencies' = 'com.linkedin:udf:1.0')", "AS", "SELECT default_foo_dali_udf2_GreaterThanHundred(a)", "FROM foo"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_dali_udf3", "tblproperties('functions' = ", "'FuncSquare:com.linkedin.coral.hive.hive2rel.CoralTestUdfSquare GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2',", " 'dependencies' = 'ivy://com.linkedin:udf:1.1 ivy://com.linkedin:udf:1.0')", "AS", "SELECT default_foo_dali_udf3_FuncSquare(a), default_foo_dali_udf3_GreaterThanHundred(a) ", "FROM foo"));
// foo_dali_udf4 is same as foo_dali_udf2, except we add extra space in dependencies parameter
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_dali_udf4", "tblproperties('functions' = 'GreaterThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF2',", " 'dependencies' = ' ivy://com.linkedin:udf:1.0 ')", "AS", "SELECT default_foo_dali_udf4_GreaterThanHundred(a)", "FROM foo"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_dali_udf5", "tblproperties('functions' = 'UnsupportedUDF:com.linkedin.coral.hive.hive2rel.CoralTestUnsupportedUDF',", " 'dependencies' = 'com.linkedin:udf:1.0')", "AS", "SELECT default_foo_dali_udf5_UnsupportedUDF(a)", "FROM foo"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_lateral_udtf", "tblproperties('functions' = 'CountOfRow:com.linkedin.coral.hive.hive2rel.CoralTestUDTF')", "AS", "SELECT a, t.col1 FROM complex LATERAL VIEW default_foo_lateral_udtf_CountOfRow(complex.a) t"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS named_struct_view", "AS", "SELECT named_struct('abc', 123, 'def', 'xyz') AS named_struc", "FROM bar"));
run(driver, String.join("\n", "", "CREATE DATABASE IF NOT EXISTS duplicate_column_name"));
run(driver, "CREATE TABLE duplicate_column_name.tableA (some_id string)");
run(driver, "CREATE TABLE duplicate_column_name.tableB (some_id string)");
run(driver, "CREATE VIEW IF NOT EXISTS duplicate_column_name.view_namesake_column_names AS " + "SELECT a.some_id FROM duplicate_column_name.tableA a LEFT JOIN (SELECT trim(some_id) AS SOME_ID FROM duplicate_column_name.tableB) b ON a.some_id = b.some_id WHERE a.some_id != ''");
// Views and tables used in FuzzyUnionViewTest
run(driver, String.join("\n", "", "CREATE DATABASE IF NOT EXISTS fuzzy_union"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableA(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view", "AS", "SELECT * from fuzzy_union.tableA", "union all", "SELECT *", "from fuzzy_union.tableA"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_with_more_than_two_tables", "AS", "SELECT *", "from fuzzy_union.tableA", "union all", "SELECT *", "from fuzzy_union.tableA", "union all", "SELECT *", "from fuzzy_union.tableA"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_with_alias", "AS", "SELECT *", "FROM", "(SELECT * from fuzzy_union.tableA)", "as viewFirst", "union all", "SELECT *", "FROM (SELECT * from fuzzy_union.tableA)", "as viewSecond"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableB(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableC(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_single_branch_evolved", "AS", "SELECT *", "from fuzzy_union.tableB", "union all", "SELECT *", "from fuzzy_union.tableC"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableC CHANGE COLUMN b b struct<b1:string, b2:int>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableD(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableE(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_double_branch_evolved_same", "AS", "SELECT *", "from fuzzy_union.tableD", "union all", "SELECT *", "from fuzzy_union.tableE"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableD CHANGE COLUMN b b struct<b1:string, b2:int>"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableE CHANGE COLUMN b b struct<b1:string, b2:int>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableF(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableG(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_double_branch_evolved_different", "AS", "SELECT *", "from fuzzy_union.tableF", "union all", "SELECT *", "from fuzzy_union.tableG"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_more_than_two_branches_evolved", "AS", "SELECT *", "from fuzzy_union.tableF", "union all", "SELECT *", "from fuzzy_union.tableG", "union all", "SELECT *", "from fuzzy_union.tableF"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableF CHANGE COLUMN b b struct<b1:string, b3:string>"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableG CHANGE COLUMN b b struct<b1:string, b2:int>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableH(a int, b map<string, struct<b1:string>>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableI(a int, b map<string, struct<b1:string>>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_map_with_struct_value_evolved", "AS", "SELECT *", "from fuzzy_union.tableH", "union all", "SELECT *", "from fuzzy_union.tableI"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableH CHANGE COLUMN b b map<string, struct<b1:string, b2:int>>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableJ(a int, b array<struct<b1:string>>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableK(a int, b array<struct<b1:string>>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_array_with_struct_value_evolved", "AS", "SELECT *", "from fuzzy_union.tableJ", "union all", "SELECT *", "from fuzzy_union.tableK"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableJ CHANGE COLUMN b b array<struct<b1:string, b2:int>>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableL(a int, b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string>>>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableM(a int, b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string>>>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_deeply_nested_struct_evolved", "AS", "SELECT *", "from fuzzy_union.tableL", "union all", "SELECT *", "from fuzzy_union.tableM"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableL CHANGE COLUMN b b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string, b6:string>>>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableN(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS fuzzy_union.tableO(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS fuzzy_union.union_view_same_schema_evolution_with_different_ordering", "AS", "SELECT *", "from fuzzy_union.tableN", "union all", "SELECT *", "from fuzzy_union.tableO"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableN CHANGE COLUMN b b struct<b2:double, b1:string, b0:int>"));
run(driver, String.join("\n", "", "ALTER TABLE fuzzy_union.tableO CHANGE COLUMN b b struct<b0:int, b1:string, b2:int>"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS schema_promotion(a int, b array<int>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS view_schema_promotion AS SELECT * from schema_promotion"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS view_schema_promotion_wrapper AS SELECT * from view_schema_promotion"));
run(driver, String.join("\n", "", "ALTER TABLE schema_promotion CHANGE COLUMN b b array<double>"));
run(driver, "CREATE TABLE IF NOT EXISTS union_table(foo uniontype<int, double, array<string>, struct<a:int,b:string>>)");
run(driver, "CREATE TABLE IF NOT EXISTS nested_union(a uniontype<int, struct<a:uniontype<int, double>, b:int>>)");
run(driver, "CREATE VIEW IF NOT EXISTS view_expand_array_index AS SELECT c[1] c1 FROM default.complex");
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS foo_duplicate_udf", "tblproperties('functions' = 'LessThanHundred:com.linkedin.coral.hive.hive2rel.CoralTestUDF',", " 'dependencies' = 'ivy://com.linkedin:udf:1.0')", "AS", "SELECT default_foo_duplicate_udf_LessThanHundred(a), default_foo_duplicate_udf_LessThanHundred(a)", "FROM foo"));
}
use of com.linkedin.coral.hive.hive2rel.HiveToRelConverter in project coral by linkedin.
the class HiveToTrinoConverter method create.
public static HiveToTrinoConverter create(HiveMetastoreClient mscClient) {
checkNotNull(mscClient);
HiveToRelConverter hiveToRelConverter = new HiveToRelConverter(mscClient);
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter();
return new HiveToTrinoConverter(hiveToRelConverter, relToTrinoConverter);
}
use of com.linkedin.coral.hive.hive2rel.HiveToRelConverter in project coral by linkedin.
the class TestUtils method initializeViews.
public static void initializeViews(HiveConf conf) throws HiveException, MetaException, IOException {
String testDir = conf.get(CORAL_TRINO_TEST_DIR);
System.out.println("Test Workspace: " + testDir);
FileUtils.deleteDirectory(new File(testDir));
SessionState.start(conf);
Driver driver = new Driver(conf);
hiveMetastoreClient = new HiveMscAdapter(Hive.get(conf).getMSC());
hiveToRelConverter = new HiveToRelConverter(hiveMetastoreClient);
// Views and tables used in HiveToTrinoConverterTest
run(driver, "CREATE DATABASE IF NOT EXISTS test");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableA(a int, b struct<b1:string>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view AS \n" + "SELECT * from test.tableA union all SELECT * from test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_with_more_than_two_tables AS \n" + "SELECT * from test.tableA union all SELECT * from test.tableA union all SELECT * from test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_with_alias AS \n" + "SELECT * FROM (SELECT * from test.tableA) as viewFirst union all SELECT * FROM (SELECT * from test.tableA) as viewSecond");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableB(a int, b struct<b1:string>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableC(a int, b struct<b1:string>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_single_branch_evolved AS \n" + "SELECT * from test.tableB union all SELECT * from test.tableC");
run(driver, "ALTER TABLE test.tableC CHANGE COLUMN b b struct<b1:string, b2:int>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableD(a int, b struct<b1:string>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableE(a int, b struct<b1:string>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_double_branch_evolved_same AS \n" + "SELECT * from test.tableD union all SELECT * from test.tableE");
run(driver, "ALTER TABLE test.tableD CHANGE COLUMN b b struct<b1:string, b2:int>");
run(driver, "ALTER TABLE test.tableE CHANGE COLUMN b b struct<b1:string, b2:int>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableF(a int, b struct<b1:string>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableG(a int, b struct<b1:string>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_double_branch_evolved_different AS \n" + "SELECT * from test.tableF union all SELECT * from test.tableG");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_more_than_two_branches_evolved AS \n" + "SELECT * from test.tableF union all SELECT * from test.tableG union all SELECT * from test.tableF");
run(driver, "ALTER TABLE test.tableF CHANGE COLUMN b b struct<b1:string, b3:string>");
run(driver, "ALTER TABLE test.tableG CHANGE COLUMN b b struct<b1:string, b2:int>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableH(a int, b map<string, struct<b1:string>>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableI(a int, b map<string, struct<b1:string>>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_map_with_struct_value_evolved AS \n" + "SELECT * from test.tableH union all SELECT * from test.tableI");
run(driver, "ALTER TABLE test.tableH CHANGE COLUMN b b map<string, struct<b1:string, b2:int>>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableJ(a int, b array<struct<b1:string>>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableK(a int, b array<struct<b1:string>>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_array_with_struct_value_evolved AS \n" + "SELECT * from test.tableJ union all SELECT * from test.tableK");
run(driver, "ALTER TABLE test.tableJ CHANGE COLUMN b b array<struct<b1:string, b2:int>>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableL(a int, b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string>>>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableM(a int, b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string>>>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_deeply_nested_struct_evolved AS \n" + "SELECT * from test.tableL union all SELECT * from test.tableM");
run(driver, "ALTER TABLE test.tableL CHANGE COLUMN b b struct<b1:string, b2:struct<b3:string, b4:struct<b5:string, b6:string>>>");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableN(a int, b struct<b1:string, m1:map<string, struct<b1:string, a1:array<struct<b1:string>>>>>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableO(a int, b struct<b1:string, m1:map<string, struct<b1:string, a1:array<struct<b1:string>>>>>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.fuzzy_union_view_deeply_nested_complex_struct_evolved AS \n" + "SELECT * from test.tableN union all SELECT * from test.tableO");
run(driver, "ALTER TABLE test.tableN CHANGE COLUMN b b struct<b1:string, m1:map<string, struct<b1:string, a1:array<struct<b0:string, b1:string>>>>>");
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS test.tableP(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE TABLE IF NOT EXISTS test.tableQ(a int, b struct<b1:string>)"));
run(driver, String.join("\n", "", "CREATE VIEW IF NOT EXISTS test.union_view_same_schema_evolution_with_different_ordering", "AS", "SELECT *", "from test.tableP", "union all", "SELECT *", "from test.tableQ"));
run(driver, String.join("\n", "", "ALTER TABLE test.tableP CHANGE COLUMN b b struct<b2:double, b1:string, b0:int>"));
run(driver, String.join("\n", "", "ALTER TABLE test.tableQ CHANGE COLUMN b b struct<b0:int, b1:string, b2:int>"));
run(driver, "CREATE TABLE test.table_with_string_array(a int, b array<string>)");
run(driver, "CREATE VIEW test.view_with_explode_string_array AS SELECT a, c FROM test.table_with_string_array LATERAL VIEW EXPLODE(b) t AS c");
run(driver, "CREATE VIEW test.view_with_outer_explode_string_array AS SELECT a, c FROM test.table_with_string_array LATERAL VIEW OUTER EXPLODE(b) t AS c");
run(driver, "CREATE TABLE test.table_with_struct_array(a int, b array<struct<sa: int, sb: string>>)");
run(driver, "CREATE VIEW test.view_with_explode_struct_array AS SELECT a, c FROM test.table_with_struct_array LATERAL VIEW EXPLODE(b) t AS c");
run(driver, "CREATE VIEW test.view_with_outer_explode_struct_array AS SELECT a, c FROM test.table_with_struct_array LATERAL VIEW OUTER EXPLODE(b) t AS c");
run(driver, "CREATE VIEW test.view_with_date_and_interval AS SELECT CAST('2021-08-30' AS DATE) + INTERVAL '3' DAY FROM test.tableA");
run(driver, "CREATE VIEW test.view_with_timestamp_and_interval AS SELECT CAST('2021-08-30' AS TIMESTAMP) + INTERVAL '-3 01:02:03' DAY TO SECOND FROM test.tableA");
run(driver, "CREATE VIEW test.view_with_timestamp_and_interval_2 AS SELECT CAST('2021-08-30' AS TIMESTAMP) + INTERVAL '-1-6' YEAR TO MONTH FROM test.tableA");
run(driver, "CREATE TABLE test.table_with_map(a int, b map<string, string>)");
run(driver, "CREATE VIEW test.view_with_explode_map AS SELECT a, c, d FROM test.table_with_map LATERAL VIEW EXPLODE(b) t AS c, d");
run(driver, "CREATE VIEW test.view_with_outer_explode_map AS SELECT a, c, d FROM test.table_with_map LATERAL VIEW OUTER EXPLODE(b) t AS c, d");
run(driver, "CREATE VIEW IF NOT EXISTS test.current_date_and_timestamp_view AS \n" + "SELECT CURRENT_TIMESTAMP, trim(cast(CURRENT_TIMESTAMP as string)) as ct, CURRENT_DATE, CURRENT_DATE as cd, a from test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.date_function_view AS \n" + "SELECT date('2021-01-02') as a from test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.lateral_view_json_tuple_view AS \n" + "SELECT a, d, e, f FROM test.tableA LATERAL VIEW json_tuple(b.b1, 'trino', 'always', 'rocks') jt AS d, e, f");
run(driver, "CREATE VIEW IF NOT EXISTS test.lateral_view_json_tuple_view_qualified AS \n" + "SELECT `t`.`a`, `jt`.`d`, `jt`.`e`, `jt`.`f` FROM `test`.`tableA` AS `t` LATERAL VIEW json_tuple(`t`.`b`.`b1`, \"trino\", \"always\", \"rocks\") `jt` AS `d`, `e`, `f`");
run(driver, "CREATE VIEW IF NOT EXISTS test.get_json_object_view AS \n" + "SELECT get_json_object(b.b1, '$.name') FROM test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.map_array_view AS \n" + "SELECT MAP('key1', 'value1', 'key2', 'value2') AS simple_map_col, " + "MAP('key1', MAP('a', 'b', 'c', 'd'), 'key2', MAP('a', 'b', 'c', 'd')) AS nested_map_col FROM test.tableA");
run(driver, "CREATE TABLE test.table_from_utc_timestamp (a_tinyint tinyint, a_smallint smallint, " + "a_integer int, a_bigint bigint, a_float float, a_double double, " + "a_decimal_three decimal(10,3), a_decimal_zero decimal(10,0), a_timestamp timestamp, " + "a_date date)");
run(driver, "CREATE VIEW test.view_from_utc_timestamp AS SELECT from_utc_timestamp(a_tinyint, 'America/Los_Angeles'), " + "from_utc_timestamp(a_smallint, 'America/Los_Angeles'), " + "from_utc_timestamp(a_integer, 'America/Los_Angeles'), " + "from_utc_timestamp(a_bigint, 'America/Los_Angeles'), " + "from_utc_timestamp(a_float, 'America/Los_Angeles'), " + "from_utc_timestamp(a_double, 'America/Los_Angeles'), " + "from_utc_timestamp(a_decimal_three, 'America/Los_Angeles'), " + "from_utc_timestamp(a_decimal_zero, 'America/Los_Angeles'), " + "from_utc_timestamp(a_timestamp, 'America/Los_Angeles'), " + "from_utc_timestamp(a_date, 'America/Los_Angeles')" + "FROM test.table_from_utc_timestamp");
run(driver, "CREATE VIEW IF NOT EXISTS test.date_calculation_view AS \n" + "SELECT to_date(substr('2021-08-20', 1, 10)), to_date('2021-08-20'), " + "to_date('2021-08-20 00:00:00'), " + "date_add('2021-08-20', 1), " + "date_add('2021-08-20 00:00:00', 1), " + "date_sub('2021-08-20', 1), " + "date_sub('2021-08-20 00:00:00', 1), " + "datediff('2021-08-20', '2021-08-21'), " + "datediff('2021-08-20', '2021-08-19'), " + "datediff('2021-08-20 00:00:00', '2021-08-19 23:59:59')" + "FROM test.tableA");
run(driver, "CREATE VIEW IF NOT EXISTS test.pmod_view AS \n" + "SELECT pmod(-9, 4) FROM test.tableA");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableR(a int, b string, c int)");
run(driver, "CREATE VIEW IF NOT EXISTS test.nullscollationd_view AS \n" + "SELECT a,b,c FROM test.tableR ORDER BY b DESC");
run(driver, "CREATE VIEW IF NOT EXISTS test.t_dot_star_view AS \n" + "SELECT ta.*, tb.b as tbb FROM test.tableA as ta JOIN test.tableA as tb ON ta.a = tb.a");
run(driver, "CREATE TABLE IF NOT EXISTS test.table_ints_strings( a int, b int, c string, d string)");
run(driver, "CREATE VIEW IF NOT EXISTS test.greatest_view AS \n" + "SELECT greatest(t.a, t.b) as g_int, greatest(t.c, t.d) as g_string FROM test.table_ints_strings t");
run(driver, "CREATE VIEW IF NOT EXISTS test.least_view AS \n" + "SELECT least(t.a, t.b) as g_int, least(t.c, t.d) as g_string FROM test.table_ints_strings t");
run(driver, "CREATE VIEW IF NOT EXISTS test.cast_decimal_view AS \n" + "SELECT CAST(t.a as DECIMAL(6,2)) as casted_decimal FROM test.table_ints_strings t");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableS (structCol struct<a:int>)");
run(driver, "CREATE TABLE IF NOT EXISTS test.tableT (structCol struct<a:int>)");
run(driver, "CREATE VIEW IF NOT EXISTS test.viewA AS SELECT structCol as struct_col FROM test.tableS");
run(driver, "CREATE VIEW IF NOT EXISTS test.viewB AS SELECT structCol as struct_col FROM test.tableT");
run(driver, "CREATE VIEW IF NOT EXISTS test.view_with_transform_column_name_reset AS SELECT struct_col AS structCol FROM (SELECT * FROM test.viewA UNION ALL SELECT * FROM test.viewB) X");
run(driver, "ALTER TABLE test.tableT CHANGE COLUMN structCol structCol struct<a:int, b:string>");
run(driver, "CREATE TABLE test.duplicate_column_name_a (some_id string)");
run(driver, "CREATE TABLE test.duplicate_column_name_b (some_id string)");
run(driver, "CREATE VIEW IF NOT EXISTS test.view_namesake_column_names AS \n" + "SELECT a.some_id FROM test.duplicate_column_name_a a LEFT JOIN ( SELECT trim(some_id) AS SOME_ID FROM test.duplicate_column_name_b) b ON a.some_id = b.some_id WHERE a.some_id != ''");
}
Aggregations