[fix](LOAD statement): fix bug for toSql func of LoadStmt. (#12648)
This commit is contained in:
@ -917,14 +917,17 @@ public class DataDescription {
|
||||
if (columnSeparator != null) {
|
||||
sb.append(" COLUMNS TERMINATED BY ").append(columnSeparator.toSql());
|
||||
}
|
||||
if (columnsFromPath != null && !columnsFromPath.isEmpty()) {
|
||||
sb.append(" COLUMNS FROM PATH AS (");
|
||||
Joiner.on(", ").appendTo(sb, columnsFromPath).append(")");
|
||||
if (fileFormat != null && !fileFormat.isEmpty()) {
|
||||
sb.append(" FORMAT AS '" + fileFormat + "'");
|
||||
}
|
||||
if (fileFieldNames != null && !fileFieldNames.isEmpty()) {
|
||||
sb.append(" (");
|
||||
Joiner.on(", ").appendTo(sb, fileFieldNames).append(")");
|
||||
}
|
||||
if (columnsFromPath != null && !columnsFromPath.isEmpty()) {
|
||||
sb.append(" COLUMNS FROM PATH AS (");
|
||||
Joiner.on(", ").appendTo(sb, columnsFromPath).append(")");
|
||||
}
|
||||
if (columnMappingList != null && !columnMappingList.isEmpty()) {
|
||||
sb.append(" SET (");
|
||||
Joiner.on(", ").appendTo(sb, Lists.transform(columnMappingList, new Function<Expr, Object>() {
|
||||
|
||||
@ -128,7 +128,7 @@ public class DataDescriptionTest {
|
||||
desc = new DataDescription("testTable", null, Lists.newArrayList("abc.txt"),
|
||||
Lists.newArrayList("col1", "col2"), new Separator(","), "csv", null, false, null, null, whereExpr, LoadTask.MergeType.MERGE, whereExpr, null, null);
|
||||
desc.analyze("testDb");
|
||||
Assert.assertEquals("MERGE DATA INFILE ('abc.txt') INTO TABLE testTable COLUMNS TERMINATED BY ',' (col1, col2) WHERE 1 = 1 DELETE ON 1 = 1", desc.toString());
|
||||
Assert.assertEquals("MERGE DATA INFILE ('abc.txt') INTO TABLE testTable COLUMNS TERMINATED BY ',' FORMAT AS 'csv' (col1, col2) WHERE 1 = 1 DELETE ON 1 = 1", desc.toString());
|
||||
Assert.assertEquals("1 = 1", desc.getWhereExpr().toSql());
|
||||
Assert.assertEquals("1 = 1", desc.getDeleteCondition().toSql());
|
||||
Assert.assertEquals(",", desc.getColumnSeparator());
|
||||
|
||||
Reference in New Issue
Block a user