Search in sources :

Example 21 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class HazelcastTable method computeRowType.

private RelDataType computeRowType(List<RexNode> projects) {
    List<RelDataTypeField> typeFields = new ArrayList<>(projects.size());
    for (int i = 0; i < projects.size(); i++) {
        RexNode project = projects.get(i);
        RelDataTypeField fieldType;
        if (project instanceof RexInputRef) {
            TableField field = target.getField(((RexInputRef) project).getIndex());
            fieldType = new RelDataTypeFieldImpl(field.getName(), i, project.getType());
            if (field.isHidden()) {
                hiddenFieldNames.add(field.getName());
            }
        } else {
            fieldType = new RelDataTypeFieldImpl("EXPR$" + i, i, project.getType());
        }
        typeFields.add(fieldType);
    }
    return new RelRecordType(StructKind.PEEK_FIELDS, typeFields, false);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) ArrayList(java.util.ArrayList) RexInputRef(org.apache.calcite.rex.RexInputRef) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl) TableField(com.hazelcast.sql.impl.schema.TableField) RelRecordType(org.apache.calcite.rel.type.RelRecordType) RelReferentialConstraint(org.apache.calcite.rel.RelReferentialConstraint) RexNode(org.apache.calcite.rex.RexNode)

Example 22 with TableField

use of com.hazelcast.sql.impl.schema.TableField in project hazelcast by hazelcast.

the class FileTableTest method test_objectKeyEquality.

@Test
@Parameters(method = "keys")
@SuppressWarnings("checkstyle:ParameterNumber")
public void test_objectKeyEquality(String schema1, String name1, String field1, FileFormat<?> format1, String schema2, String name2, String field2, FileFormat<?> format2, boolean expected) {
    FilePlanObjectKey k1 = new FilePlanObjectKey(schema1, name1, ImmutableList.of(new TableField(field1, QueryDataType.INT, false)), new ProcessorMetaSupplierProvider(ImmutableMap.of("key", "value"), format1));
    FilePlanObjectKey k2 = new FilePlanObjectKey(schema2, name2, singletonList(new TableField(field2, QueryDataType.INT, false)), new ProcessorMetaSupplierProvider(singletonMap("key", "value"), format2));
    assertThat(k1.equals(k2)).isEqualTo(expected);
    assertThat(k1.hashCode() == k2.hashCode()).isEqualTo(expected);
}
Also used : FilePlanObjectKey(com.hazelcast.jet.sql.impl.connector.file.FileTable.FilePlanObjectKey) TableField(com.hazelcast.sql.impl.schema.TableField) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

TableField (com.hazelcast.sql.impl.schema.TableField)22 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)15 QueryPath (com.hazelcast.sql.impl.extract.QueryPath)13 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)12 ArrayList (java.util.ArrayList)10 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)8 MappingField (com.hazelcast.sql.impl.schema.MappingField)7 KvMetadata (com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata)5 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)5 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)4 IndexScanMapPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel)4 Nonnull (javax.annotation.Nonnull)3 Test (org.junit.Test)3 ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)2 Parameters (junitparams.Parameters)2 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)2 ImmutableList (com.google.common.collect.ImmutableList)1 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 Schema (com.hazelcast.internal.serialization.impl.compact.Schema)1 FilePlanObjectKey (com.hazelcast.jet.sql.impl.connector.file.FileTable.FilePlanObjectKey)1