You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */packageorg.apache.wayang.api.sql.calcite.converter;
importorg.apache.calcite.rel.type.RelDataType;
importorg.apache.calcite.rel.type.RelDataTypeField;
importorg.apache.wayang.api.sql.calcite.rel.WayangTableScan;
importorg.apache.wayang.api.sql.calcite.utils.ModelParser;
importorg.apache.wayang.api.sql.sources.fs.JavaCSVTableSource;
importorg.apache.wayang.core.plan.wayangplan.Operator;
importorg.apache.wayang.core.types.DataSetType;
importorg.apache.wayang.postgres.operators.PostgresTableSource;
importorg.apache.wayang.basic.data.Record;
importjava.util.ArrayList;
importjava.util.List;
importjava.util.Objects;
//TODO: create tablesource with column types//TODO: support other sourcespublicclassWayangTableScanVisitorextendsWayangRelNodeVisitor<WayangTableScan> {
WayangTableScanVisitor(WayangRelConverterwayangRelConverter) {
super(wayangRelConverter);
}
@OverrideOperatorvisit(WayangTableScanwayangRelNode) {
StringtableName = wayangRelNode.getTableName();
List<String> columnNames = wayangRelNode.getColumnNames();
// Get the source platform for this tableStringtableSource = wayangRelNode.getTable().getQualifiedName().get(0);
if (tableSource.equals("postgres")) {
returnnewPostgresTableSource(tableName, columnNames.toArray(newString[]{}));
}
if (tableSource.equals("fs")) {
ModelParsermodelParser;
try {
modelParser = newModelParser();
} catch (Exceptione) {
thrownewRuntimeException(e);
}
RelDataTyperowType = wayangRelNode.getRowType();
List<RelDataType> fieldTypes = newArrayList<>();
for (RelDataTypeFieldfield : rowType.getFieldList()) {
fieldTypes.add(field.getType());
}
Stringurl = String.format("file:/%s/%s.csv", modelParser.getFsPath(), wayangRelNode.getTableName());
Stringseparator = modelParser.getSeparator();
if (Objects.equals(separator, "")) {
returnnewJavaCSVTableSource(url,
DataSetType.createDefault(Record.class), fieldTypes);
} else {
returnnewJavaCSVTableSource(url,
DataSetType.createDefault(Record.class), fieldTypes, separator.charAt(0));
}
} elsethrownewRuntimeException("Source not supported");
}
}
b1c72b5fff03637d9e0384743555a36ca97ca266
The text was updated successfully, but these errors were encountered:
create tablesource with column types
https://github.com/databloom-ai/incubator-wayang/blob/c51b95e414816ed2b6ac7f8f3cad5857b40fea3b/wayang-api/wayang-api-sql/src/main/java/org/apache/wayang/api/sql/calcite/converter/WayangTableScanVisitor.java#L36
b1c72b5fff03637d9e0384743555a36ca97ca266
The text was updated successfully, but these errors were encountered: