File tree 3 files changed +24
-56
lines changed
seatunnel-transforms-v2/src
main/java/org/apache/seatunnel/transform/sql/zeta
test/java/org/apache/seatunnel/transform/sql
3 files changed +24
-56
lines changed Original file line number Diff line number Diff line change 24
24
import org .apache .seatunnel .transform .exception .TransformException ;
25
25
import org .apache .seatunnel .transform .sql .SQLEngine ;
26
26
27
+ import org .slf4j .Logger ;
28
+ import org .slf4j .LoggerFactory ;
29
+
27
30
import net .sf .jsqlparser .JSQLParserException ;
28
31
import net .sf .jsqlparser .expression .Expression ;
29
32
import net .sf .jsqlparser .parser .CCJSqlParserUtil ;
46
49
import java .util .stream .Collectors ;
47
50
48
51
public class ZetaSQLEngine implements SQLEngine {
52
+ private static final Logger log = LoggerFactory .getLogger (ZetaSQLEngine .class );
49
53
private String inputTableName ;
50
54
@ Nullable private String catalogTableName ;
51
55
private SeaTunnelRowType inputRowType ;
@@ -119,8 +123,11 @@ private void validateSQL(Statement statement) {
119
123
String tableName = table .getName ();
120
124
if (!inputTableName .equalsIgnoreCase (tableName )
121
125
&& !tableName .equalsIgnoreCase (catalogTableName )) {
122
- throw new IllegalArgumentException (
123
- String .format ("Table name: %s not found" , tableName ));
126
+ log .warn (
127
+ "SQL table name {} is not equal to input table name {} or catalog table name {}" ,
128
+ tableName ,
129
+ inputTableName ,
130
+ catalogTableName );
124
131
}
125
132
} else {
126
133
throw new IllegalArgumentException ("Unsupported sub table syntax" );
Original file line number Diff line number Diff line change @@ -69,6 +69,21 @@ public void testScaleSupport() {
69
69
});
70
70
}
71
71
72
+ @ Test
73
+ public void testQueryWithAnyTable () {
74
+ SQLTransform sqlTransform =
75
+ new SQLTransform (
76
+ ReadonlyConfig .fromMap (
77
+ new HashMap <String , Object >() {
78
+ {
79
+ put ("query" , "select * from anyTableName" );
80
+ }
81
+ }),
82
+ getCatalogTable ());
83
+ TableSchema tableSchema = sqlTransform .transformTableSchema ();
84
+ Assertions .assertEquals (4 , tableSchema .getColumns ().size ());
85
+ }
86
+
72
87
@ Test
73
88
public void testNotLoseSourceTypeAndOptions () {
74
89
SQLTransform sqlTransform = new SQLTransform (READONLY_CONFIG , getCatalogTable ());
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments