Skip to content

Commit

Permalink
add comment + update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGe00 committed Sep 26, 2024
1 parent e8cbdd0 commit 6e7d3e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ import org.slf4j.LoggerFactory;
this.hiveConf = hiveConf;
}
protected boolean useSQL11ReservedKeywordsForIdentifier() {
/*
* This enables the translation of keywords as column names without adding backquotes. This is required for translating views
* created using spark engine as certain keywords in hive like timestamp are not keywords in spark. This will
* result in creation of views without backquoting those keywords. This should return false when coral-spark becomes
* a supported LHS for translations.
*/
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@ public static TestHive setupDefaultHive(HiveConf conf) throws IOException {
driver.run("CREATE VIEW IF NOT EXISTS view_schema_evolve_wrapper AS SELECT * from view_schema_evolve");
driver.run("ALTER TABLE schema_evolve CHANGE COLUMN b b array<struct<b1:string, b2:double, b3:int>>");

driver.run("CREATE OR REPLACE VIEW test.spark_created_view AS SELECT 1 AS `timestamp` FROM test.tableOne");
// Simulate the creation of view using spark by setting the corresponding table property of the view.
driver.run("ALTER VIEW test.spark_created_view SET TBLPROPERTIES ('spark.sql.create.version'='3.1.1')");
driver.run(
"CREATE OR REPLACE VIEW test.quoted_reserved_keyword_view AS SELECT 1 AS `timestamp` FROM test.tableOne");

CommandProcessorResponse response = driver
.run("create function test_tableOneView_LessThanHundred as 'com.linkedin.coral.hive.hive2rel.CoralTestUDF'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ public void testUnsupportedOuterExplodeWithoutColumns() {
}

/**
* Validates if coral-hive can translate views with unquoted reserved keywords when the views are created using spark.
* Validates if coral-hive can translate views with unquoted reserved keywords as column names.
*/
@Test
public void testUnquotedKeywordAsColumnName() {
HiveToRelConverter hiveToRelConverter = new HiveToRelConverter(msc);
Table table = msc.getTable("test", "spark_created_view");
Table table = msc.getTable("test", "quoted_reserved_keyword_view");
// Remove the backquotes associated with the view text
String input = table.getViewExpandedText().replaceAll("`", "");
SqlNode sqlNode = hiveToRelConverter.toSqlNode(input, table);
Expand Down

0 comments on commit 6e7d3e1

Please sign in to comment.