mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for hive sql format, fix #4092
This commit is contained in:
@@ -10398,6 +10398,13 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
print0(ucase ? " BUCKETS" : " buckets");
|
||||
}
|
||||
|
||||
SQLExprTableSource like = x.getLike();
|
||||
if (like != null) {
|
||||
println();
|
||||
print0(ucase ? "LIKE " : "like ");
|
||||
like.accept(this);
|
||||
}
|
||||
|
||||
SQLExpr storedAs = x.getStoredAs();
|
||||
if (storedAs != null) {
|
||||
println();
|
||||
@@ -10441,13 +10448,6 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
println();
|
||||
visit(select);
|
||||
}
|
||||
|
||||
SQLExprTableSource like = x.getLike();
|
||||
if (like != null) {
|
||||
println();
|
||||
print0(ucase ? "LIKE " : "like ");
|
||||
like.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void printSerdeProperties(Map<String, SQLObject> serdeProperties) {
|
||||
|
||||
@@ -46,10 +46,10 @@ public class HiveCreateTableTest_36_dla extends OracleTest {
|
||||
String text = SQLUtils.toSQLString(stmt, JdbcConstants.HIVE);
|
||||
|
||||
assertEquals("CREATE TABLE dla_table1\n" +
|
||||
"LIKE dla_table2\n" +
|
||||
"TBLPROPERTIES (\n" +
|
||||
"\t'column_mapping' = 'hello,world;james,bond;'\n" +
|
||||
")\n" +
|
||||
"LIKE dla_table2;", text);
|
||||
");", text);
|
||||
}
|
||||
|
||||
System.out.println("Tables : " + visitor.getTables());
|
||||
|
||||
@@ -29,10 +29,10 @@ public class HiveCreateTableTest_46_dla extends OracleTest {
|
||||
SQLStatement stmt = SQLUtils.parseSingleStatement(sql, DbType.hive, SQLParserFeature.KeepComments);
|
||||
|
||||
assertEquals("CREATE EXTERNAL TABLE parquet_tbl\n" +
|
||||
"LIKE MAPPING('oss://user/etl/destination/datafile1.dat')\n" +
|
||||
"TBLPROPERTIES (\n" +
|
||||
"\t'target.table.location' = 'oss://user/etl/destination/'\n" +
|
||||
")\n" +
|
||||
"LIKE MAPPING('oss://user/etl/destination/datafile1.dat')", stmt.toString());
|
||||
")", stmt.toString());
|
||||
|
||||
assertEquals(stmt.toString(), SQLUtils.parseSingleStatement(stmt.toString(), DbType.hive, SQLParserFeature.KeepComments).toString());
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ public class HiveResourceTest extends TestCase {
|
||||
exec_test("bvt/parser/hive-2.txt");
|
||||
}
|
||||
|
||||
public void test_3() throws Exception {
|
||||
exec_test("bvt/parser/hive-3.txt");
|
||||
}
|
||||
|
||||
public void exec_test(String resource) throws Exception {
|
||||
// System.out.println(resource);
|
||||
InputStream is = null;
|
||||
|
||||
@@ -3,5 +3,5 @@ like ads_data.sale_detail_one1
|
||||
STORED AS parquet
|
||||
---------------------------
|
||||
CREATE TABLE ads_data.sale_detail_one23
|
||||
STORED AS parquet
|
||||
LIKE ads_data.sale_detail_one1
|
||||
LIKE ads_data.sale_detail_one1
|
||||
STORED AS parquet
|
||||
Reference in New Issue
Block a user