本文整理汇总了Java中org.apache.calcite.rel.type.RelDataType.getFieldList方法的典型用法代码示例。如果您正苦于以下问题:Java RelDataType.getFieldList方法的具体用法?Java RelDataType.getFieldList怎么用?Java RelDataType.getFieldList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.type.RelDataType
的用法示例。
在下文中一共展示了RelDataType.getFieldList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deriveCopiedRowTypeFromInput
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Derive rowType for the copied WindowPrel based on input.
* When copy() is called, the input might be different from the current one's input.
* We have to use the new input's field in the copied WindowPrel.
*/
private RelDataType deriveCopiedRowTypeFromInput(final RelNode input) {
final RelDataType inputRowType = input.getRowType();
final RelDataType windowRowType = this.getRowType();
final List<RelDataTypeField> fieldList = new ArrayList<>(inputRowType.getFieldList());
final int inputFieldCount = inputRowType.getFieldCount();
final int windowFieldCount = windowRowType.getFieldCount();
for (int i = inputFieldCount; i < windowFieldCount; i++) {
fieldList.add(windowRowType.getFieldList().get(i));
}
final RelDataType rowType = this.getCluster().getRexBuilder().getTypeFactory().createStructType(fieldList);
return rowType;
}
示例2: areRowTypesEqual
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Verifies that two row type names match.
* Does not compare nullability.
* Differs from RelOptUtil implementation by not defining types as equal if one is of type ANY.
*
* @param rowType1 row type for comparison
* @param rowType2 row type for comparison
*
* @return boolean indicating that rel data types are equivalent
*/
public static boolean areRowTypesEqual(
RelDataType rowType1,
RelDataType rowType2) {
if (rowType1 == rowType2) {
return true;
}
if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
return false;
}
final List<RelDataTypeField> f1 = rowType1.getFieldList();
final List<RelDataTypeField> f2 = rowType2.getFieldList();
for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
final RelDataType type1 = pair.left.getType();
final RelDataType type2 = pair.right.getType();
// Compare row type names.
if (!type1.equals(type2)) {
return false;
}
}
return true;
}
示例3: fromCalciteRowTypeJson
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static BatchSchema fromCalciteRowTypeJson(final RelDataType relDataType){
Preconditions.checkArgument(relDataType.isStruct());
SchemaBuilder builder = BatchSchema.newBuilder();
for (Map.Entry<String,RelDataType> field : relDataType.getFieldList()) {
MinorType minorType = TypeInferenceUtils.getMinorTypeFromCalciteType(field.getValue());
if (minorType != null) {
// if we're using json/rels reader, the types are going to be larger than typical.
if(minorType == MinorType.INT){
minorType = MinorType.BIGINT;
}
if(minorType == MinorType.FLOAT4){
minorType = MinorType.FLOAT8;
}
Field f = MajorTypeHelper.getFieldForNameAndMajorType(field.getKey(), Types.optional(minorType));
builder.addField(f);
}
}
return builder.build();
}
示例4: getRelDataType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
@Override
RelProtoDataType getRelDataType(
DatabaseMetaData metaData,
String catalogName,
String schemaName,
String tableName
) throws SQLException {
if (journalledTableKeys.containsKey(tableName)) {
// 1: Find columns for journal table
RelDataType relDataType = super
.getRelDataType(metaData, catalogName, schemaName, journalNameFor(tableName))
.apply(new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT) {
@Override
public RelDataType copyType(RelDataType type) {
return type;
}
});
RelDataTypeFactory.FieldInfoBuilder fieldInfo = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT).builder();
// 2: Filter out journal-implementation columns
for (RelDataTypeField field : relDataType.getFieldList()) {
String fieldName = field.getName();
if (fieldName.equals(versionField) || fieldName.equals(subsequentVersionField)) {
continue;
}
fieldInfo.add(field);
}
return RelDataTypeImpl.proto(fieldInfo.build());
} else {
return super.getRelDataType(metaData, catalogName, schemaName, tableName);
}
}
示例5: containIdentity
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Returns whether the leading edge of a given array of expressions is
* wholly {@link RexInputRef} objects with types and names corresponding
* to the underlying row type. */
private static boolean containIdentity(List<? extends RexNode> exps,
RelDataType rowType, RelDataType childRowType) {
List<RelDataTypeField> fields = rowType.getFieldList();
List<RelDataTypeField> childFields = childRowType.getFieldList();
int fieldCount = childFields.size();
if (exps.size() != fieldCount) {
return false;
}
for (int i = 0; i < exps.size(); i++) {
RexNode exp = exps.get(i);
if (!(exp instanceof RexInputRef)) {
return false;
}
RexInputRef var = (RexInputRef) exp;
if (var.getIndex() != i) {
return false;
}
if (!fields.get(i).getName().equals(childFields.get(i).getName())) {
return false;
}
if (!fields.get(i).getType().equals(childFields.get(i).getType())) {
return false;
}
}
return true;
}
示例6: View
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public View(String name, String sql, RelDataType rowType, List<String> workspaceSchemaPath) {
this.name = name;
this.sql = sql;
fields = Lists.newArrayList();
for (RelDataTypeField f : rowType.getFieldList()) {
fields.add(new FieldType(f.getName(), f.getType()));
}
this.workspaceSchemaPath =
workspaceSchemaPath == null ? ImmutableList.<String>of() : ImmutableList.copyOf(workspaceSchemaPath);
}
示例7: scanSchema
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Recursively scans the given schema, invoking the visitor as appropriate.
* @param schemaPath the path to the given schema, so far
* @param schema the given schema
*/
private void scanSchema(String schemaPath, SchemaPlus schema) {
// Recursively scan any subschema.
for (String name: schema.getSubSchemaNames()) {
scanSchema(schemaPath +
(schemaPath == "" ? "" : ".") + // If we have an empty schema path, then don't insert a leading dot.
name, schema.getSubSchema(name));
}
// Visit this schema and if requested ...
if (shouldVisitSchema(schemaPath, schema) && visitSchema(schemaPath, schema)) {
// ... do for each of the schema's tables.
for (String tableName: schema.getTableNames()) {
Table table = schema.getTable(tableName);
if (table == null) {
// Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
// tables as INFO SCHEMA is about showing tables which the use has access to query.
continue;
}
// Visit the table, and if requested ...
if (shouldVisitTable(schemaPath, tableName) && visitTable(schemaPath, tableName, table)) {
// ... do for each of the table's fields.
RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
for (RelDataTypeField field: tableRow.getFieldList()) {
visitField(schemaPath, tableName, field);
}
}
}
}
}
示例8: renameAsNecessary
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
private Prel renameAsNecessary(RelDataType expectedRowType, Prel initialInput) {
if(RelOptUtil.areRowTypesEqual(initialInput.getRowType(), expectedRowType, false) && !RelOptUtil.areRowTypesEqual(initialInput.getRowType(), expectedRowType, true)) {
final List<RexNode> refs = new ArrayList<>();
final List<RelDataTypeField> fields = expectedRowType.getFieldList();
final RexBuilder rb = initialInput.getCluster().getRexBuilder();
for(int i = 0; i < expectedRowType.getFieldCount(); i++) {
refs.add(rb.makeInputRef(fields.get(i).getType(), i));
}
return new ProjectPrel(initialInput.getCluster(), initialInput.getTraitSet(), initialInput, refs, expectedRowType);
} else {
return initialInput;
}
}
示例9: containIdentity
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Returns whether the leading edge of a given array of expressions is
* wholly {@link RexInputRef} objects with types and names corresponding
* to the underlying row type. */
public static boolean containIdentity(List<? extends RexNode> exps,
RelDataType rowType, RelDataType childRowType) {
List<RelDataTypeField> fields = rowType.getFieldList();
List<RelDataTypeField> childFields = childRowType.getFieldList();
int fieldCount = childFields.size();
if (exps.size() != fieldCount) {
return false;
}
for (int i = 0; i < exps.size(); i++) {
RexNode exp = exps.get(i);
if (!(exp instanceof RexInputRef)) {
return false;
}
RexInputRef var = (RexInputRef) exp;
if (var.getIndex() != i) {
return false;
}
if (!fields.get(i).getName().equals(childFields.get(i).getName())) {
return false;
}
if (!fields.get(i).getType().equals(childFields.get(i).getType())) {
return false;
}
}
return true;
}
示例10: fromCalciteRowType
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static BatchSchema fromCalciteRowType(final RelDataType relDataType){
Preconditions.checkArgument(relDataType.isStruct());
SchemaBuilder builder = BatchSchema.newBuilder();
for (Map.Entry<String,RelDataType> field : relDataType.getFieldList()) {
MinorType minorType = TypeInferenceUtils.getMinorTypeFromCalciteType(field.getValue());
if (minorType != null) {
Field f = MajorTypeHelper.getFieldForNameAndMajorType(field.getKey(), Types.optional(minorType));
builder.addField(f);
}
}
return builder.build();
}
示例11: isStarQuery
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean isStarQuery(RelDataType rowType){
for(RelDataTypeField field : rowType.getFieldList()){
if(STAR_COLUMN.equals(field.getName())){
return true;
}
}
return false;
}
示例12: RefFieldsVisitor
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public RefFieldsVisitor(RelDataType rowType) {
super(true);
this.fieldNames = rowType.getFieldNames();
this.fields = rowType.getFieldList();
}
示例13: areRowTypesCompatible
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean areRowTypesCompatible(
RelDataType rowType1,
RelDataType rowType2,
boolean compareNames,
boolean allowSubstring) {
if (rowType1 == rowType2) {
return true;
}
if (compareNames) {
// if types are not identity-equal, then either the names or
// the types must be different
return false;
}
if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
return false;
}
final List<RelDataTypeField> f1 = rowType1.getFieldList();
final List<RelDataTypeField> f2 = rowType2.getFieldList();
for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
final RelDataType type1 = pair.left.getType();
final RelDataType type2 = pair.right.getType();
// If one of the types is ANY comparison should succeed
if (type1.getSqlTypeName() == SqlTypeName.ANY
|| type2.getSqlTypeName() == SqlTypeName.ANY) {
continue;
}
if (type1.getSqlTypeName() != type2.getSqlTypeName()) {
if (allowSubstring
&& (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
&& (type1.getPrecision() <= type2.getPrecision())) {
return true;
}
// Check if Drill implicit casting can resolve the incompatibility
List<TypeProtos.MinorType> types = Lists.newArrayListWithCapacity(2);
types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName()));
types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName()));
if(TypeCastRules.getLeastRestrictiveType(types) != null) {
return true;
}
return false;
}
}
return true;
}
示例14: areRowTypesCompatible
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
public static boolean areRowTypesCompatible(
RelDataType rowType1,
RelDataType rowType2,
boolean compareNames,
boolean allowSubstring) {
if (rowType1 == rowType2) {
return true;
}
if (compareNames) {
// if types are not identity-equal, then either the names or
// the types must be different
return false;
}
if (rowType2.getFieldCount() != rowType1.getFieldCount()) {
return false;
}
final List<RelDataTypeField> f1 = rowType1.getFieldList();
final List<RelDataTypeField> f2 = rowType2.getFieldList();
for (Pair<RelDataTypeField, RelDataTypeField> pair : Pair.zip(f1, f2)) {
final RelDataType type1 = pair.left.getType();
final RelDataType type2 = pair.right.getType();
// If one of the types is ANY comparison should succeed
if (type1.getSqlTypeName() == SqlTypeName.ANY
|| type2.getSqlTypeName() == SqlTypeName.ANY) {
continue;
}
if (type1.getSqlTypeName() != type2.getSqlTypeName()) {
if (allowSubstring
&& (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR)
&& (type1.getPrecision() <= type2.getPrecision())) {
return true;
}
// Check if Dremio implicit casting can resolve the incompatibility
List<TypeProtos.MinorType> types = Lists.newArrayListWithCapacity(2);
types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName()));
types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName()));
if(TypeCastRules.getLeastRestrictiveType(types) != null) {
return true;
}
return false;
}
}
return true;
}
示例15: scanSchema
import org.apache.calcite.rel.type.RelDataType; //导入方法依赖的package包/类
/**
* Scan the schame tree, invoking the visitor as appropriate.
* @param rootSchema the given schema
*/
public void scanSchema(SchemaPlus rootSchema) {
if (!shouldVisitCatalog() || !visitCatalog()) {
return;
}
// Visit this schema and if requested ...
for (String subSchemaName: rootSchema.getSubSchemaNames()) {
final SchemaPlus firstLevelSchema = rootSchema.getSubSchema(subSchemaName);
if (shouldVisitSchema(subSchemaName, firstLevelSchema) && visitSchema(subSchemaName, firstLevelSchema)) {
final AbstractSchema schemaInstance;
try{
schemaInstance = (AbstractSchema) firstLevelSchema.unwrap(AbstractSchema.class).getDefaultSchema();
}catch(Exception ex){
logger.warn("Failure reading schema {}. Skipping inclusion in INFORMATION_SCHEMA.", subSchemaName, ex);
continue;
}
// ... do for each of the schema's tables.
for (String tableName : firstLevelSchema.getTableNames()) {
try {
final TableInfo tableInfo = schemaInstance.getTableInfo(tableName);
if (tableInfo == null) {
// Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
// tables as INFO SCHEMA is about showing tables which the user has access to query.
continue;
}
final Table table;
if (tableInfo.getTable() == null) {
table = schemaInstance.getTable(tableName);
} else {
table = tableInfo.getTable();
}
final TableType tableType = table.getJdbcTableType();
// Visit the table, and if requested ...
if (shouldVisitTable(subSchemaName, tableName, tableType) && visitTable(subSchemaName, tableName, tableInfo)) {
// ... do for each of the table's fields.
RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
for (RelDataTypeField field : tableRow.getFieldList()) {
if (shouldVisitColumn(subSchemaName, tableName, field.getName())) {
visitField(subSchemaName, tableName, field);
}
}
}
} catch (Exception e) {
Joiner joiner = Joiner.on('.');
String path = joiner.join(joiner.join(firstLevelSchema.getTableNames()), tableName);
logger.warn("Failure while trying to read schema for table {}. Skipping inclusion in INFORMATION_SCHEMA.", path, e);;
continue;
}
}
}
}
}