Skip to content

Commit

Permalink
remove char sets from TrinoSqlDialect (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGe00 authored Oct 13, 2023
1 parent 7e7bf89 commit a7e33e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ private TrinoSqlDialect(Context context) {
super(context);
}

@Override
public boolean supportsCharSet() {
return false;
}

/**
* Override this method so that so that table alias is prepended to all field references (e.g., "table.column"
* or "table.struct.filed" instead of "column" or "struct.field"), which is necessary for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ private static SqlDataTypeSpec convertTypeSpec(SqlDataTypeSpec type) {
final SqlBasicTypeNameSpec realTypeName =
new SqlBasicTypeNameSpec(SqlTypeName.REAL, precision, scale, charSetName, parserPos);
return new SqlDataTypeSpec(realTypeName, timeZone, parserPos);
case "VARCHAR":
final SqlBasicTypeNameSpec varcharTypeName =
new SqlBasicTypeNameSpec(SqlTypeName.VARCHAR, precision, scale, null, parserPos); // remove CHARACTER SET
return new SqlDataTypeSpec(varcharTypeName, timeZone, parserPos);
case "CHAR":
final SqlBasicTypeNameSpec charTypeName =
new SqlBasicTypeNameSpec(SqlTypeName.CHAR, precision, scale, null, parserPos); // remove CHARACTER SET
return new SqlDataTypeSpec(charTypeName, timeZone, parserPos);
default:
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,19 @@ public void testNamedStructWithArrayWithoutType() {
assertEquals(expandedSql, targetSql);
}

@Test
public void testNestedNamedStructWithArrayWithoutType() {
RelNode relNode =
TestUtils.getHiveToRelConverter().convertSql("SELECT NAMED_STRUCT('value', NAMED_STRUCT('value2', ARRAY()))");
String targetSql =
"SELECT CAST(ROW(CAST(ROW(ARRAY[]) AS ROW(\"value2\" ARRAY<VARCHAR(65535)>))) AS ROW(\"value\" ROW(\"value2\" ARRAY<VARCHAR(65535)>)))\n"
+ "FROM (VALUES (0)) AS \"t\" (\"ZERO\")";

RelToTrinoConverter relToTrinoConverter = TestUtils.getRelToTrinoConverter();
String expandedSql = relToTrinoConverter.convert(relNode);
assertEquals(expandedSql, targetSql);
}

@Test
public void testNamedStructWithStringTypeArray() {
RelNode relNode =
Expand Down

0 comments on commit a7e33e6

Please sign in to comment.