Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Coral-Trino] Remove characters sets from TrinoSqlDialect #460

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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