File tree Expand file tree Collapse file tree
wayang-commons/wayang-basic/src/main/java/org/apache/wayang/basic/operators
wayang-platforms/wayang-jdbc-template/src/main/java/org/apache/wayang/jdbc/operators Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929public class TableSource extends UnarySource <Record > {
3030
3131 private final String tableName ;
32+ private final String [] columnNames ; // Line 32
33+
34+ // Add this method somewhere around line 35
35+ public String [] getColumnNames () {
36+ return this .columnNames ;
37+ }
3238
3339 public String getTableName () {
3440 return tableName ;
@@ -42,12 +48,15 @@ public String getTableName() {
4248 * into Wayang, so as to allow specific optimizations
4349 */
4450 public TableSource (String tableName , String ... columnNames ) {
45- this (tableName , createOutputDataSetType (columnNames ));
51+ super (createOutputDataSetType (columnNames ));
52+ this .tableName = tableName ;
53+ this .columnNames = columnNames ; // Assigned here!
4654 }
4755
4856 public TableSource (String tableName , DataSetType <Record > type ) {
4957 super (type );
5058 this .tableName = tableName ;
59+ this .columnNames =new String [0 ];
5160 }
5261
5362 /**
@@ -71,6 +80,7 @@ private static DataSetType<Record> createOutputDataSetType(String[] columnNames)
7180 public TableSource (TableSource that ) {
7281 super (that );
7382 this .tableName = that .getTableName ();
83+ this .columnNames = that .getColumnNames (); // ADD THIS LINE HERE!
7484 }
7585
7686}
Original file line number Diff line number Diff line change @@ -55,9 +55,16 @@ public JdbcTableSource(JdbcTableSource that) {
5555
5656 @ Override
5757 public String createSqlClause (Connection connection , FunctionCompiler compiler ) {
58- return this .getTableName ();
59- }
58+ // Call the method we just created in the parent
59+ String [] cols = this .getColumnNames ();
60+
61+ if (cols == null || cols .length == 0 ) {
62+ return String .format ("SELECT * FROM %s" , this .getTableName ());
63+ }
6064
65+ String columns = String .join (", " , cols );
66+ return String .format ("SELECT %s FROM %s" , columns , this .getTableName ());
67+ }
6168
6269 @ Override
6370 public String getLoadProfileEstimatorConfigurationKey () {
You can’t perform that action at this time.
0 commit comments