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

[Improve][Transform-V2] Remove SQL query validation on table name #7020

Merged
merged 2 commits into from
Jun 20, 2024
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 @@ -24,6 +24,9 @@
import org.apache.seatunnel.transform.exception.TransformException;
import org.apache.seatunnel.transform.sql.SQLEngine;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
Expand All @@ -46,6 +49,7 @@
import java.util.stream.Collectors;

public class ZetaSQLEngine implements SQLEngine {
private static final Logger log = LoggerFactory.getLogger(ZetaSQLEngine.class);
private String inputTableName;
@Nullable private String catalogTableName;
private SeaTunnelRowType inputRowType;
Expand Down Expand Up @@ -119,8 +123,11 @@ private void validateSQL(Statement statement) {
String tableName = table.getName();
if (!inputTableName.equalsIgnoreCase(tableName)
&& !tableName.equalsIgnoreCase(catalogTableName)) {
throw new IllegalArgumentException(
String.format("Table name: %s not found", tableName));
log.warn(
"SQL table name {} is not equal to input table name {} or catalog table name {}",
tableName,
inputTableName,
catalogTableName);
}
} else {
throw new IllegalArgumentException("Unsupported sub table syntax");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ public void testScaleSupport() {
});
}

@Test
public void testQueryWithAnyTable() {
SQLTransform sqlTransform =
new SQLTransform(
ReadonlyConfig.fromMap(
new HashMap<String, Object>() {
{
put("query", "select * from anyTableName");
}
}),
getCatalogTable());
TableSchema tableSchema = sqlTransform.transformTableSchema();
Assertions.assertEquals(4, tableSchema.getColumns().size());
}

@Test
public void testNotLoseSourceTypeAndOptions() {
SQLTransform sqlTransform = new SQLTransform(READONLY_CONFIG, getCatalogTable());
Expand Down

This file was deleted.

Loading