bug fix for clickhouse ddl output

This commit is contained in:
shaojin.wensj
2022-06-13 14:58:51 +08:00
parent e6723bf650
commit ddf13aa41a
3 changed files with 43 additions and 0 deletions
@@ -109,4 +109,31 @@ public class ClickhouseOutputVisitor extends SQLASTOutputVisitor implements Clic
printAndAccept(x.getColumns(), ", ");
return false;
}
@Override
public boolean visit(SQLArrayDataType x) {
final List<SQLExpr> arguments = x.getArguments();
if (Boolean.TRUE.equals(x.getAttribute("ads.arrayDataType"))) {
x.getComponentType().accept(this);
print('[');
printAndAccept(arguments, ", ");
print(']');
} else {
SQLDataType componentType = x.getComponentType();
if (componentType != null) {
print0(ucase ? "Array<" : "array<");
componentType.accept(this);
print('>');
} else {
print0(ucase ? "Array" : "array");
}
if (arguments.size() > 0) {
print('(');
printAndAccept(arguments, ", ");
print(')');
}
}
return false;
}
}
@@ -91,6 +91,10 @@ public class ClickHouseResourceTest extends OracleTest {
exec_test("bvt/parser/clickhouse-13.txt");
}
public void test_14() throws Exception {
exec_test("bvt/parser/clickhouse-14.txt");
}
public void exec_test(String resource) throws Exception {
System.out.println(resource);
InputStream is = null;
@@ -0,0 +1,12 @@
CREATE TABLE if not exists etda.mytable1
(
`id` UInt64,
`action_parameter_uint64_list` Array(UInt64),
`action_parameter_string_list` Array(String)
)
---------------------------
CREATE TABLE IF NOT EXISTS etda.mytable1 (
`id` UInt64,
`action_parameter_uint64_list` Array(UInt64),
`action_parameter_string_list` Array(String)
)