Search in sources :

Example 6 with SMALLINT

use of io.trino.spi.type.SmallintType.SMALLINT in project trino by trinodb.

the class TestSignatureBinder method testFunction.

@Test
public void testFunction() {
    Signature simple = functionSignature().returnType(BOOLEAN.getTypeSignature()).argumentTypes(functionType(INTEGER.getTypeSignature(), INTEGER.getTypeSignature())).build();
    assertThat(simple).boundTo(INTEGER).fails();
    assertThat(simple).boundTo(new FunctionType(ImmutableList.of(INTEGER), INTEGER)).succeeds();
    // TODO: Support coercion of return type of lambda
    assertThat(simple).boundTo(new FunctionType(ImmutableList.of(INTEGER), SMALLINT)).withCoercion().fails();
    assertThat(simple).boundTo(new FunctionType(ImmutableList.of(INTEGER), BIGINT)).withCoercion().fails();
    Signature applyTwice = functionSignature().returnType(new TypeSignature("V")).argumentTypes(new TypeSignature("T"), functionType(new TypeSignature("T"), new TypeSignature("U")), functionType(new TypeSignature("U"), new TypeSignature("V"))).typeVariableConstraints(typeVariable("T"), typeVariable("U"), typeVariable("V")).build();
    assertThat(applyTwice).boundTo(INTEGER, INTEGER, INTEGER).fails();
    assertThat(applyTwice).boundTo(INTEGER, new FunctionType(ImmutableList.of(INTEGER), VARCHAR), new FunctionType(ImmutableList.of(VARCHAR), DOUBLE)).produces(new BoundVariables().setTypeVariable("T", INTEGER).setTypeVariable("U", VARCHAR).setTypeVariable("V", DOUBLE));
    assertThat(applyTwice).boundTo(INTEGER, new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(INTEGER), VARCHAR).getTypeSignature()), new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(VARCHAR), DOUBLE).getTypeSignature())).produces(new BoundVariables().setTypeVariable("T", INTEGER).setTypeVariable("U", VARCHAR).setTypeVariable("V", DOUBLE));
    assertThat(applyTwice).boundTo(// pass function argument to non-function position of a function
    new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(INTEGER), VARCHAR).getTypeSignature()), new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(INTEGER), VARCHAR).getTypeSignature()), new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(VARCHAR), DOUBLE).getTypeSignature())).fails();
    assertThat(applyTwice).boundTo(new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(INTEGER), VARCHAR).getTypeSignature()), // pass non-function argument to function position of a function
    INTEGER, new TypeSignatureProvider(functionArgumentTypes -> new FunctionType(ImmutableList.of(VARCHAR), DOUBLE).getTypeSignature())).fails();
    Signature flatMap = functionSignature().returnType(arrayType(new TypeSignature("T"))).argumentTypes(arrayType(new TypeSignature("T")), functionType(new TypeSignature("T"), arrayType(new TypeSignature("T")))).typeVariableConstraints(typeVariable("T")).build();
    assertThat(flatMap).boundTo(new ArrayType(INTEGER), new FunctionType(ImmutableList.of(INTEGER), new ArrayType(INTEGER))).produces(new BoundVariables().setTypeVariable("T", INTEGER));
    Signature varargApply = functionSignature().returnType(new TypeSignature("T")).argumentTypes(new TypeSignature("T"), functionType(new TypeSignature("T"), new TypeSignature("T"))).typeVariableConstraints(typeVariable("T")).setVariableArity(true).build();
    assertThat(varargApply).boundTo(INTEGER, new FunctionType(ImmutableList.of(INTEGER), INTEGER), new FunctionType(ImmutableList.of(INTEGER), INTEGER), new FunctionType(ImmutableList.of(INTEGER), INTEGER)).produces(new BoundVariables().setTypeVariable("T", INTEGER));
    assertThat(varargApply).boundTo(INTEGER, new FunctionType(ImmutableList.of(INTEGER), INTEGER), new FunctionType(ImmutableList.of(INTEGER), DOUBLE), new FunctionType(ImmutableList.of(DOUBLE), DOUBLE)).fails();
    Signature loop = functionSignature().returnType(new TypeSignature("T")).argumentTypes(new TypeSignature("T"), functionType(new TypeSignature("T"), new TypeSignature("T"))).typeVariableConstraints(typeVariable("T")).build();
    assertThat(loop).boundTo(INTEGER, new TypeSignatureProvider(paramTypes -> new FunctionType(paramTypes, BIGINT).getTypeSignature())).fails();
    assertThat(loop).boundTo(INTEGER, new TypeSignatureProvider(paramTypes -> new FunctionType(paramTypes, BIGINT).getTypeSignature())).withCoercion().produces(new BoundVariables().setTypeVariable("T", BIGINT));
    // TODO: Support coercion of return type of lambda
    assertThat(loop).withCoercion().boundTo(INTEGER, new TypeSignatureProvider(paramTypes -> new FunctionType(paramTypes, SMALLINT).getTypeSignature())).fails();
    // TODO: Support coercion of return type of lambda
    // Without coercion support for return type of lambda, the return type of lambda must be `varchar(x)` to avoid need for coercions.
    Signature varcharApply = functionSignature().returnType(VARCHAR.getTypeSignature()).argumentTypes(VARCHAR.getTypeSignature(), functionType(VARCHAR.getTypeSignature(), new TypeSignature("varchar", TypeSignatureParameter.typeVariable("x")))).build();
    assertThat(varcharApply).withCoercion().boundTo(createVarcharType(10), new TypeSignatureProvider(paramTypes -> new FunctionType(paramTypes, createVarcharType(1)).getTypeSignature())).succeeds();
    Signature sortByKey = functionSignature().returnType(arrayType(new TypeSignature("T"))).argumentTypes(arrayType(new TypeSignature("T")), functionType(new TypeSignature("T"), new TypeSignature("E"))).typeVariableConstraints(typeVariable("T"), orderableTypeParameter("E")).build();
    assertThat(sortByKey).boundTo(new ArrayType(INTEGER), new TypeSignatureProvider(paramTypes -> new FunctionType(paramTypes, VARCHAR).getTypeSignature())).produces(new BoundVariables().setTypeVariable("T", INTEGER).setTypeVariable("E", VARCHAR));
}
Also used : TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) ArrayType(io.trino.spi.type.ArrayType) TypeSignatureProvider.fromTypes(io.trino.sql.analyzer.TypeSignatureProvider.fromTypes) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) UNKNOWN(io.trino.type.UnknownType.UNKNOWN) Test(org.testng.annotations.Test) TypeSignatureParameter.anonymousField(io.trino.spi.type.TypeSignatureParameter.anonymousField) FunctionType(io.trino.type.FunctionType) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) Signature.castableFromTypeParameter(io.trino.metadata.Signature.castableFromTypeParameter) INTEGER(io.trino.spi.type.IntegerType.INTEGER) Assert.assertFalse(org.testng.Assert.assertFalse) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TypeSignature(io.trino.spi.type.TypeSignature) RowType(io.trino.spi.type.RowType) ImmutableSet(com.google.common.collect.ImmutableSet) Signature.castableToTypeParameter(io.trino.metadata.Signature.castableToTypeParameter) ArrayType(io.trino.spi.type.ArrayType) Assert.assertNotNull(org.testng.Assert.assertNotNull) String.format(java.lang.String.format) Signature.orderableTypeParameter(io.trino.metadata.Signature.orderableTypeParameter) List(java.util.List) BIGINT(io.trino.spi.type.BigintType.BIGINT) Signature.typeVariable(io.trino.metadata.Signature.typeVariable) Optional(java.util.Optional) TypeSignature.mapType(io.trino.spi.type.TypeSignature.mapType) TypeSignatureParameter(io.trino.spi.type.TypeSignatureParameter) Signature.comparableTypeParameter(io.trino.metadata.Signature.comparableTypeParameter) TIMESTAMP_MILLIS(io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS) Type(io.trino.spi.type.Type) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) Assert.assertEquals(org.testng.Assert.assertEquals) HYPER_LOG_LOG(io.trino.spi.type.HyperLogLogType.HYPER_LOG_LOG) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Objects.requireNonNull(java.util.Objects.requireNonNull) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) TypeSignature.functionType(io.trino.spi.type.TypeSignature.functionType) TypeSignatureParameter.numericParameter(io.trino.spi.type.TypeSignatureParameter.numericParameter) TypeSignature.arrayType(io.trino.spi.type.TypeSignature.arrayType) DecimalType.createDecimalType(io.trino.spi.type.DecimalType.createDecimalType) Assert.fail(org.testng.Assert.fail) Signature.withVariadicBound(io.trino.metadata.Signature.withVariadicBound) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) TypeSignature.rowType(io.trino.spi.type.TypeSignature.rowType) PLANNER_CONTEXT(io.trino.sql.planner.TestingPlannerContext.PLANNER_CONTEXT) TypeSignatureProvider(io.trino.sql.analyzer.TypeSignatureProvider) Assert.assertTrue(org.testng.Assert.assertTrue) TINYINT(io.trino.spi.type.TinyintType.TINYINT) VarcharType.createVarcharType(io.trino.spi.type.VarcharType.createVarcharType) JSON(io.trino.type.JsonType.JSON) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) TypeSignature(io.trino.spi.type.TypeSignature) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) TypeSignature(io.trino.spi.type.TypeSignature) FunctionType(io.trino.type.FunctionType) Test(org.testng.annotations.Test)

Example 7 with SMALLINT

use of io.trino.spi.type.SmallintType.SMALLINT in project trino by trinodb.

the class TupleDomainParquetPredicate method getDomain.

/**
 * Get a domain for the ranges defined by each pair of elements from {@code minimums} and {@code maximums}.
 * Both arrays must have the same length.
 */
private static Domain getDomain(ColumnDescriptor column, Type type, List<Object> minimums, List<Object> maximums, boolean hasNullValue, DateTimeZone timeZone) {
    checkArgument(minimums.size() == maximums.size(), "Expected minimums and maximums to have the same size");
    if (type.equals(BOOLEAN)) {
        boolean hasTrueValues = minimums.stream().anyMatch(value -> (boolean) value) || maximums.stream().anyMatch(value -> (boolean) value);
        boolean hasFalseValues = minimums.stream().anyMatch(value -> !(boolean) value) || maximums.stream().anyMatch(value -> !(boolean) value);
        if (hasTrueValues && hasFalseValues) {
            return Domain.all(type);
        }
        if (hasTrueValues) {
            return Domain.create(ValueSet.of(type, true), hasNullValue);
        }
        if (hasFalseValues) {
            return Domain.create(ValueSet.of(type, false), hasNullValue);
        }
        // All nulls case is handled earlier
        throw new VerifyException("Impossible boolean statistics");
    }
    if (type.equals(BIGINT) || type.equals(INTEGER) || type.equals(DATE) || type.equals(SMALLINT) || type.equals(TINYINT)) {
        List<Range> ranges = new ArrayList<>();
        for (int i = 0; i < minimums.size(); i++) {
            long min = asLong(minimums.get(i));
            long max = asLong(maximums.get(i));
            if (isStatisticsOverflow(type, min, max)) {
                return Domain.create(ValueSet.all(type), hasNullValue);
            }
            ranges.add(Range.range(type, min, true, max, true));
        }
        return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
    }
    if (type instanceof DecimalType) {
        DecimalType decimalType = (DecimalType) type;
        List<Range> ranges = new ArrayList<>();
        if (decimalType.isShort()) {
            for (int i = 0; i < minimums.size(); i++) {
                Object min = minimums.get(i);
                Object max = maximums.get(i);
                long minValue = min instanceof Binary ? getShortDecimalValue(((Binary) min).getBytes()) : asLong(min);
                long maxValue = min instanceof Binary ? getShortDecimalValue(((Binary) max).getBytes()) : asLong(max);
                if (isStatisticsOverflow(type, minValue, maxValue)) {
                    return Domain.create(ValueSet.all(type), hasNullValue);
                }
                ranges.add(Range.range(type, minValue, true, maxValue, true));
            }
        } else {
            for (int i = 0; i < minimums.size(); i++) {
                Int128 min = Int128.fromBigEndian(((Binary) minimums.get(i)).getBytes());
                Int128 max = Int128.fromBigEndian(((Binary) maximums.get(i)).getBytes());
                ranges.add(Range.range(type, min, true, max, true));
            }
        }
        return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
    }
    if (type.equals(REAL)) {
        List<Range> ranges = new ArrayList<>();
        for (int i = 0; i < minimums.size(); i++) {
            Float min = (Float) minimums.get(i);
            Float max = (Float) maximums.get(i);
            if (min.isNaN() || max.isNaN()) {
                return Domain.create(ValueSet.all(type), hasNullValue);
            }
            ranges.add(Range.range(type, (long) floatToRawIntBits(min), true, (long) floatToRawIntBits(max), true));
        }
        return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
    }
    if (type.equals(DOUBLE)) {
        List<Range> ranges = new ArrayList<>();
        for (int i = 0; i < minimums.size(); i++) {
            Double min = (Double) minimums.get(i);
            Double max = (Double) maximums.get(i);
            if (min.isNaN() || max.isNaN()) {
                return Domain.create(ValueSet.all(type), hasNullValue);
            }
            ranges.add(Range.range(type, min, true, max, true));
        }
        return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
    }
    if (type instanceof VarcharType) {
        List<Range> ranges = new ArrayList<>();
        for (int i = 0; i < minimums.size(); i++) {
            Slice min = Slices.wrappedBuffer(((Binary) minimums.get(i)).toByteBuffer());
            Slice max = Slices.wrappedBuffer(((Binary) maximums.get(i)).toByteBuffer());
            ranges.add(Range.range(type, min, true, max, true));
        }
        return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
    }
    if (type instanceof TimestampType) {
        if (column.getPrimitiveType().getPrimitiveTypeName().equals(INT96)) {
            TrinoTimestampEncoder<?> timestampEncoder = createTimestampEncoder((TimestampType) type, timeZone);
            List<Object> values = new ArrayList<>();
            for (int i = 0; i < minimums.size(); i++) {
                Object min = minimums.get(i);
                Object max = maximums.get(i);
                // available and valid in that special case
                if (!(min instanceof Binary) || !(max instanceof Binary) || !min.equals(max)) {
                    return Domain.create(ValueSet.all(type), hasNullValue);
                }
                values.add(timestampEncoder.getTimestamp(decodeInt96Timestamp((Binary) min)));
            }
            return Domain.multipleValues(type, values, hasNullValue);
        }
        if (column.getPrimitiveType().getPrimitiveTypeName().equals(INT64)) {
            LogicalTypeAnnotation logicalTypeAnnotation = column.getPrimitiveType().getLogicalTypeAnnotation();
            if (!(logicalTypeAnnotation instanceof TimestampLogicalTypeAnnotation)) {
                // Invalid statistics. Unit and UTC adjustment are not known
                return Domain.create(ValueSet.all(type), hasNullValue);
            }
            TimestampLogicalTypeAnnotation timestampTypeAnnotation = (TimestampLogicalTypeAnnotation) logicalTypeAnnotation;
            // Bail out if the precision is not known
            if (timestampTypeAnnotation.getUnit() == null) {
                return Domain.create(ValueSet.all(type), hasNullValue);
            }
            TrinoTimestampEncoder<?> timestampEncoder = createTimestampEncoder((TimestampType) type, DateTimeZone.UTC);
            List<Range> ranges = new ArrayList<>();
            for (int i = 0; i < minimums.size(); i++) {
                long min = (long) minimums.get(i);
                long max = (long) maximums.get(i);
                ranges.add(Range.range(type, timestampEncoder.getTimestamp(decodeInt64Timestamp(min, timestampTypeAnnotation.getUnit())), true, timestampEncoder.getTimestamp(decodeInt64Timestamp(max, timestampTypeAnnotation.getUnit())), true));
            }
            return Domain.create(ValueSet.ofRanges(ranges), hasNullValue);
        }
    }
    return Domain.create(ValueSet.all(type), hasNullValue);
}
Also used : PrimitiveType(org.apache.parquet.schema.PrimitiveType) DateTimeZone(org.joda.time.DateTimeZone) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) ColumnIndex(org.apache.parquet.internal.column.columnindex.ColumnIndex) FilterApi(org.apache.parquet.filter2.predicate.FilterApi) ByteBuffer(java.nio.ByteBuffer) INT96(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT96) TrinoTimestampEncoderFactory.createTimestampEncoder(io.trino.plugin.base.type.TrinoTimestampEncoderFactory.createTimestampEncoder) ParquetDataSourceId(io.trino.parquet.ParquetDataSourceId) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Slices(io.airlift.slice.Slices) Map(java.util.Map) INTEGER(io.trino.spi.type.IntegerType.INTEGER) UserDefinedPredicate(org.apache.parquet.filter2.predicate.UserDefinedPredicate) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) PredicateUtils.isStatisticsOverflow(io.trino.parquet.predicate.PredicateUtils.isStatisticsOverflow) Range(io.trino.spi.predicate.Range) TimestampLogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) Domain(io.trino.spi.predicate.Domain) ParquetTimestampUtils.decodeInt96Timestamp(io.trino.parquet.ParquetTimestampUtils.decodeInt96Timestamp) Dictionary(io.trino.parquet.dictionary.Dictionary) ColumnIndexStore(org.apache.parquet.internal.filter2.columnindex.ColumnIndexStore) String.format(java.lang.String.format) ValueSet(io.trino.spi.predicate.ValueSet) Binary(org.apache.parquet.io.api.Binary) Serializable(java.io.Serializable) INT64(org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64) List(java.util.List) TrinoTimestampEncoder(io.trino.plugin.base.type.TrinoTimestampEncoder) BIGINT(io.trino.spi.type.BigintType.BIGINT) LITTLE_ENDIAN(java.nio.ByteOrder.LITTLE_ENDIAN) ColumnDescriptor(org.apache.parquet.column.ColumnDescriptor) Optional(java.util.Optional) Operators(org.apache.parquet.filter2.predicate.Operators) DecimalType(io.trino.spi.type.DecimalType) DATE(io.trino.spi.type.DateType.DATE) REAL(io.trino.spi.type.RealType.REAL) ParquetCorruptionException(io.trino.parquet.ParquetCorruptionException) ColumnPath(org.apache.parquet.hadoop.metadata.ColumnPath) Slice(io.airlift.slice.Slice) Type(io.trino.spi.type.Type) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) Function(java.util.function.Function) TimestampType(io.trino.spi.type.TimestampType) ArrayList(java.util.ArrayList) VarcharType(io.trino.spi.type.VarcharType) Float.floatToRawIntBits(java.lang.Float.floatToRawIntBits) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) RichColumnDescriptor(io.trino.parquet.RichColumnDescriptor) VerifyException(com.google.common.base.VerifyException) Int128(io.trino.spi.type.Int128) Statistics(org.apache.parquet.column.statistics.Statistics) DictionaryPage(io.trino.parquet.DictionaryPage) ParquetTimestampUtils.decodeInt64Timestamp(io.trino.parquet.ParquetTimestampUtils.decodeInt64Timestamp) ParquetTypeUtils.getShortDecimalValue(io.trino.parquet.ParquetTypeUtils.getShortDecimalValue) TupleDomain(io.trino.spi.predicate.TupleDomain) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TINYINT(io.trino.spi.type.TinyintType.TINYINT) VarcharType(io.trino.spi.type.VarcharType) ArrayList(java.util.ArrayList) Range(io.trino.spi.predicate.Range) VerifyException(com.google.common.base.VerifyException) TimestampLogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) LogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation) Slice(io.airlift.slice.Slice) TimestampLogicalTypeAnnotation(org.apache.parquet.schema.LogicalTypeAnnotation.TimestampLogicalTypeAnnotation) DecimalType(io.trino.spi.type.DecimalType) TimestampType(io.trino.spi.type.TimestampType) Binary(org.apache.parquet.io.api.Binary) Int128(io.trino.spi.type.Int128)

Example 8 with SMALLINT

use of io.trino.spi.type.SmallintType.SMALLINT in project trino by trinodb.

the class MySqlClient method toColumnMapping.

@Override
public Optional<ColumnMapping> toColumnMapping(ConnectorSession session, Connection connection, JdbcTypeHandle typeHandle) {
    String jdbcTypeName = typeHandle.getJdbcTypeName().orElseThrow(() -> new TrinoException(JDBC_ERROR, "Type name is missing: " + typeHandle));
    Optional<ColumnMapping> mapping = getForcedMappingToVarchar(typeHandle);
    if (mapping.isPresent()) {
        return mapping;
    }
    switch(jdbcTypeName.toLowerCase(ENGLISH)) {
        case "tinyint unsigned":
            return Optional.of(smallintColumnMapping());
        case "smallint unsigned":
            return Optional.of(integerColumnMapping());
        case "int unsigned":
            return Optional.of(bigintColumnMapping());
        case "bigint unsigned":
            return Optional.of(decimalColumnMapping(createDecimalType(20)));
        case "json":
            return Optional.of(jsonColumnMapping());
    }
    switch(typeHandle.getJdbcType()) {
        case Types.BIT:
            return Optional.of(booleanColumnMapping());
        case Types.TINYINT:
            return Optional.of(tinyintColumnMapping());
        case Types.SMALLINT:
            return Optional.of(smallintColumnMapping());
        case Types.INTEGER:
            return Optional.of(integerColumnMapping());
        case Types.BIGINT:
            return Optional.of(bigintColumnMapping());
        case Types.REAL:
            // attempts to treat them as exact in comparisons may lead to problems
            return Optional.of(ColumnMapping.longMapping(REAL, (resultSet, columnIndex) -> floatToRawIntBits(resultSet.getFloat(columnIndex)), realWriteFunction(), DISABLE_PUSHDOWN));
        case Types.DOUBLE:
            return Optional.of(doubleColumnMapping());
        case Types.NUMERIC:
        case Types.DECIMAL:
            int decimalDigits = typeHandle.getDecimalDigits().orElseThrow(() -> new IllegalStateException("decimal digits not present"));
            int precision = typeHandle.getRequiredColumnSize();
            if (getDecimalRounding(session) == ALLOW_OVERFLOW && precision > Decimals.MAX_PRECISION) {
                int scale = min(decimalDigits, getDecimalDefaultScale(session));
                return Optional.of(decimalColumnMapping(createDecimalType(Decimals.MAX_PRECISION, scale), getDecimalRoundingMode(session)));
            }
            // TODO does mysql support negative scale?
            // Map decimal(p, -s) (negative scale) to decimal(p+s, 0).
            precision = precision + max(-decimalDigits, 0);
            if (precision > Decimals.MAX_PRECISION) {
                break;
            }
            return Optional.of(decimalColumnMapping(createDecimalType(precision, max(decimalDigits, 0))));
        case Types.CHAR:
            return Optional.of(defaultCharColumnMapping(typeHandle.getRequiredColumnSize(), false));
        // TODO not all these type constants are necessarily used by the JDBC driver
        case Types.VARCHAR:
        case Types.NVARCHAR:
        case Types.LONGVARCHAR:
        case Types.LONGNVARCHAR:
            return Optional.of(defaultVarcharColumnMapping(typeHandle.getRequiredColumnSize(), false));
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            return Optional.of(ColumnMapping.sliceMapping(VARBINARY, varbinaryReadFunction(), varbinaryWriteFunction(), FULL_PUSHDOWN));
        case Types.DATE:
            return Optional.of(dateColumnMappingUsingLocalDate());
        case Types.TIME:
            TimeType timeType = createTimeType(getTimePrecision(typeHandle.getRequiredColumnSize()));
            return Optional.of(timeColumnMapping(timeType));
        case Types.TIMESTAMP:
            TimestampType timestampType = createTimestampType(getTimestampPrecision(typeHandle.getRequiredColumnSize()));
            return Optional.of(timestampColumnMapping(timestampType));
    }
    if (getUnsupportedTypeHandling(session) == CONVERT_TO_VARCHAR) {
        return mapToUnboundedVarchar(typeHandle);
    }
    return Optional.empty();
}
Also used : AggregateFunction(io.trino.spi.connector.AggregateFunction) StandardColumnMappings.bigintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.bigintWriteFunction) ImplementCount(io.trino.plugin.jdbc.aggregation.ImplementCount) JdbcStatement(com.mysql.cj.jdbc.JdbcStatement) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) StandardColumnMappings.booleanColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.booleanColumnMapping) StandardColumnMappings.defaultVarcharColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.defaultVarcharColumnMapping) ResultSet(java.sql.ResultSet) Map(java.util.Map) StandardColumnMappings.doubleWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.doubleWriteFunction) ImplementVarianceSamp(io.trino.plugin.jdbc.aggregation.ImplementVarianceSamp) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) DecimalSessionSessionProperties.getDecimalDefaultScale(io.trino.plugin.jdbc.DecimalSessionSessionProperties.getDecimalDefaultScale) ENGLISH(java.util.Locale.ENGLISH) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TypeHandlingJdbcSessionProperties.getUnsupportedTypeHandling(io.trino.plugin.jdbc.TypeHandlingJdbcSessionProperties.getUnsupportedTypeHandling) ImplementStddevSamp(io.trino.plugin.jdbc.aggregation.ImplementStddevSamp) ImplementAvgFloatingPoint(io.trino.plugin.jdbc.aggregation.ImplementAvgFloatingPoint) ImplementCountAll(io.trino.plugin.jdbc.aggregation.ImplementCountAll) StandardColumnMappings.longTimestampWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.longTimestampWriteFunction) PreparedStatement(java.sql.PreparedStatement) SchemaTableName(io.trino.spi.connector.SchemaTableName) Collectors.joining(java.util.stream.Collectors.joining) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) Stream(java.util.stream.Stream) StandardColumnMappings.smallintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.smallintWriteFunction) StandardColumnMappings.longDecimalWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.longDecimalWriteFunction) AggregateFunctionRewriter(io.trino.plugin.base.aggregation.AggregateFunctionRewriter) ConnectionFactory(io.trino.plugin.jdbc.ConnectionFactory) StandardColumnMappings.timeColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.timeColumnMapping) CONVERT_TO_VARCHAR(io.trino.plugin.jdbc.UnsupportedTypeHandling.CONVERT_TO_VARCHAR) JdbcConnectorExpressionRewriterBuilder(io.trino.plugin.jdbc.expression.JdbcConnectorExpressionRewriterBuilder) StandardColumnMappings.dateColumnMappingUsingLocalDate(io.trino.plugin.jdbc.StandardColumnMappings.dateColumnMappingUsingLocalDate) JdbcTableHandle(io.trino.plugin.jdbc.JdbcTableHandle) DATE(io.trino.spi.type.DateType.DATE) REAL(io.trino.spi.type.RealType.REAL) SQL_STATE_ER_TABLE_EXISTS_ERROR(com.mysql.cj.exceptions.MysqlErrorNumbers.SQL_STATE_ER_TABLE_EXISTS_ERROR) JoinCondition(io.trino.spi.connector.JoinCondition) StandardColumnMappings.doubleColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.doubleColumnMapping) StandardColumnMappings.booleanWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.booleanWriteFunction) ALLOW_OVERFLOW(io.trino.plugin.jdbc.DecimalConfig.DecimalMapping.ALLOW_OVERFLOW) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) DatabaseMetaData(java.sql.DatabaseMetaData) StandardColumnMappings.bigintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.bigintColumnMapping) StandardColumnMappings.timeWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.timeWriteFunction) TimestampType(io.trino.spi.type.TimestampType) StandardColumnMappings.defaultCharColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.defaultCharColumnMapping) ImplementVariancePop(io.trino.plugin.jdbc.aggregation.ImplementVariancePop) Float.floatToRawIntBits(java.lang.Float.floatToRawIntBits) SQLException(java.sql.SQLException) TIMESTAMP_TZ_MILLIS(io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS) String.join(java.lang.String.join) FULL_PUSHDOWN(io.trino.plugin.jdbc.PredicatePushdownController.FULL_PUSHDOWN) StandardColumnMappings.charWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.charWriteFunction) PreparedQuery(io.trino.plugin.jdbc.PreparedQuery) StandardColumnMappings.decimalColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.decimalColumnMapping) ColumnHandle(io.trino.spi.connector.ColumnHandle) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) ConnectorExpressionRewriter(io.trino.plugin.base.expression.ConnectorExpressionRewriter) AggregateFunctionRule(io.trino.plugin.base.aggregation.AggregateFunctionRule) StandardColumnMappings.realWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.realWriteFunction) DecimalType.createDecimalType(io.trino.spi.type.DecimalType.createDecimalType) QueryBuilder(io.trino.plugin.jdbc.QueryBuilder) StandardColumnMappings.varbinaryReadFunction(io.trino.plugin.jdbc.StandardColumnMappings.varbinaryReadFunction) StandardColumnMappings.smallintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.smallintColumnMapping) StandardTypes(io.trino.spi.type.StandardTypes) ConnectorSession(io.trino.spi.connector.ConnectorSession) ImplementAvgDecimal(io.trino.plugin.jdbc.aggregation.ImplementAvgDecimal) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) IdentifierMapping(io.trino.plugin.jdbc.mapping.IdentifierMapping) Strings.emptyToNull(com.google.common.base.Strings.emptyToNull) CharType(io.trino.spi.type.CharType) DecimalSessionSessionProperties.getDecimalRoundingMode(io.trino.plugin.jdbc.DecimalSessionSessionProperties.getDecimalRoundingMode) StandardColumnMappings.timestampColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.timestampColumnMapping) TINYINT(io.trino.spi.type.TinyintType.TINYINT) StandardColumnMappings.shortDecimalWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.shortDecimalWriteFunction) StandardColumnMappings.varbinaryWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.varbinaryWriteFunction) JdbcExpression(io.trino.plugin.jdbc.JdbcExpression) WriteMapping(io.trino.plugin.jdbc.WriteMapping) JDBC_ERROR(io.trino.plugin.jdbc.JdbcErrorCode.JDBC_ERROR) BaseJdbcConfig(io.trino.plugin.jdbc.BaseJdbcConfig) Connection(java.sql.Connection) BiFunction(java.util.function.BiFunction) ImplementSum(io.trino.plugin.jdbc.aggregation.ImplementSum) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) TimestampType.createTimestampType(io.trino.spi.type.TimestampType.createTimestampType) ColumnMapping(io.trino.plugin.jdbc.ColumnMapping) ALREADY_EXISTS(io.trino.spi.StandardErrorCode.ALREADY_EXISTS) INTEGER(io.trino.spi.type.IntegerType.INTEGER) ImplementStddevPop(io.trino.plugin.jdbc.aggregation.ImplementStddevPop) TypeSignature(io.trino.spi.type.TypeSignature) ImmutableSet(com.google.common.collect.ImmutableSet) DecimalSessionSessionProperties.getDecimalRounding(io.trino.plugin.jdbc.DecimalSessionSessionProperties.getDecimalRounding) Collection(java.util.Collection) TrinoException(io.trino.spi.TrinoException) Math.min(java.lang.Math.min) String.format(java.lang.String.format) JdbcSortItem(io.trino.plugin.jdbc.JdbcSortItem) List(java.util.List) JdbcTypeHandle(io.trino.plugin.jdbc.JdbcTypeHandle) BIGINT(io.trino.spi.type.BigintType.BIGINT) Decimals(io.trino.spi.type.Decimals) Optional(java.util.Optional) Math.max(java.lang.Math.max) StandardColumnMappings.tinyintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.tinyintColumnMapping) DecimalType(io.trino.spi.type.DecimalType) StandardColumnMappings.integerColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.integerColumnMapping) Types(java.sql.Types) StandardColumnMappings.timestampWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.timestampWriteFunction) TimeType(io.trino.spi.type.TimeType) StandardColumnMappings.varcharWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.varcharWriteFunction) StandardColumnMappings.tinyintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.tinyintWriteFunction) Type(io.trino.spi.type.Type) TimeType.createTimeType(io.trino.spi.type.TimeType.createTimeType) Inject(javax.inject.Inject) VarcharType(io.trino.spi.type.VarcharType) TIME_WITH_TIME_ZONE(io.trino.spi.type.TimeWithTimeZoneType.TIME_WITH_TIME_ZONE) SQL_STATE_SYNTAX_ERROR(com.mysql.cj.exceptions.MysqlErrorNumbers.SQL_STATE_SYNTAX_ERROR) JoinStatistics(io.trino.spi.connector.JoinStatistics) JoinType(io.trino.spi.connector.JoinType) Verify.verify(com.google.common.base.Verify.verify) JsonTypeUtil.jsonParse(io.trino.plugin.base.util.JsonTypeUtil.jsonParse) BaseJdbcClient(io.trino.plugin.jdbc.BaseJdbcClient) RemoteTableName(io.trino.plugin.jdbc.RemoteTableName) JdbcJoinCondition(io.trino.plugin.jdbc.JdbcJoinCondition) ImplementMinMax(io.trino.plugin.jdbc.aggregation.ImplementMinMax) JdbcColumnHandle(io.trino.plugin.jdbc.JdbcColumnHandle) StandardColumnMappings.integerWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.integerWriteFunction) StandardColumnMappings.dateWriteFunctionUsingLocalDate(io.trino.plugin.jdbc.StandardColumnMappings.dateWriteFunctionUsingLocalDate) DISABLE_PUSHDOWN(io.trino.plugin.jdbc.PredicatePushdownController.DISABLE_PUSHDOWN) TypeManager(io.trino.spi.type.TypeManager) TrinoException(io.trino.spi.TrinoException) TimestampType(io.trino.spi.type.TimestampType) TimestampType.createTimestampType(io.trino.spi.type.TimestampType.createTimestampType) StandardColumnMappings.booleanColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.booleanColumnMapping) StandardColumnMappings.defaultVarcharColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.defaultVarcharColumnMapping) StandardColumnMappings.timeColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.timeColumnMapping) StandardColumnMappings.doubleColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.doubleColumnMapping) StandardColumnMappings.bigintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.bigintColumnMapping) StandardColumnMappings.defaultCharColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.defaultCharColumnMapping) StandardColumnMappings.decimalColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.decimalColumnMapping) StandardColumnMappings.smallintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.smallintColumnMapping) StandardColumnMappings.timestampColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.timestampColumnMapping) ColumnMapping(io.trino.plugin.jdbc.ColumnMapping) StandardColumnMappings.tinyintColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.tinyintColumnMapping) StandardColumnMappings.integerColumnMapping(io.trino.plugin.jdbc.StandardColumnMappings.integerColumnMapping) ImplementAvgFloatingPoint(io.trino.plugin.jdbc.aggregation.ImplementAvgFloatingPoint) TimeType(io.trino.spi.type.TimeType) TimeType.createTimeType(io.trino.spi.type.TimeType.createTimeType)

Example 9 with SMALLINT

use of io.trino.spi.type.SmallintType.SMALLINT in project trino by trinodb.

the class OracleClient method toColumnMapping.

@Override
public Optional<ColumnMapping> toColumnMapping(ConnectorSession session, Connection connection, JdbcTypeHandle typeHandle) {
    String jdbcTypeName = typeHandle.getJdbcTypeName().orElseThrow(() -> new TrinoException(JDBC_ERROR, "Type name is missing: " + typeHandle));
    Optional<ColumnMapping> mappingToVarchar = getForcedMappingToVarchar(typeHandle);
    if (mappingToVarchar.isPresent()) {
        return mappingToVarchar;
    }
    if (jdbcTypeName.equalsIgnoreCase("date")) {
        return Optional.of(ColumnMapping.longMapping(TIMESTAMP_SECONDS, oracleTimestampReadFunction(), trinoTimestampToOracleDateWriteFunction(), FULL_PUSHDOWN));
    }
    switch(typeHandle.getJdbcType()) {
        case Types.SMALLINT:
            return Optional.of(ColumnMapping.longMapping(SMALLINT, ResultSet::getShort, smallintWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.BINARY_FLOAT:
            return Optional.of(ColumnMapping.longMapping(REAL, (resultSet, columnIndex) -> floatToRawIntBits(resultSet.getFloat(columnIndex)), oracleRealWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.BINARY_DOUBLE:
        case OracleTypes.FLOAT:
            return Optional.of(ColumnMapping.doubleMapping(DOUBLE, ResultSet::getDouble, oracleDoubleWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.NUMBER:
            int actualPrecision = typeHandle.getRequiredColumnSize();
            int decimalDigits = typeHandle.getRequiredDecimalDigits();
            // Map negative scale to decimal(p+s, 0).
            int precision = actualPrecision + max(-decimalDigits, 0);
            int scale = max(decimalDigits, 0);
            Optional<Integer> numberDefaultScale = getNumberDefaultScale(session);
            RoundingMode roundingMode = getNumberRoundingMode(session);
            if (precision < scale) {
                if (roundingMode == RoundingMode.UNNECESSARY) {
                    break;
                }
                scale = min(Decimals.MAX_PRECISION, scale);
                precision = scale;
            } else if (numberDefaultScale.isPresent() && precision == PRECISION_OF_UNSPECIFIED_NUMBER) {
                precision = Decimals.MAX_PRECISION;
                scale = numberDefaultScale.get();
            } else if (precision > Decimals.MAX_PRECISION || actualPrecision <= 0) {
                break;
            }
            DecimalType decimalType = createDecimalType(precision, scale);
            // JDBC driver can return BigDecimal with lower scale than column's scale when there are trailing zeroes
            if (decimalType.isShort()) {
                return Optional.of(ColumnMapping.longMapping(decimalType, shortDecimalReadFunction(decimalType, roundingMode), shortDecimalWriteFunction(decimalType), FULL_PUSHDOWN));
            }
            return Optional.of(ColumnMapping.objectMapping(decimalType, longDecimalReadFunction(decimalType, roundingMode), longDecimalWriteFunction(decimalType), FULL_PUSHDOWN));
        case OracleTypes.CHAR:
        case OracleTypes.NCHAR:
            CharType charType = createCharType(typeHandle.getRequiredColumnSize());
            return Optional.of(ColumnMapping.sliceMapping(charType, charReadFunction(charType), oracleCharWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.VARCHAR:
        case OracleTypes.NVARCHAR:
            return Optional.of(ColumnMapping.sliceMapping(createVarcharType(typeHandle.getRequiredColumnSize()), (varcharResultSet, varcharColumnIndex) -> utf8Slice(varcharResultSet.getString(varcharColumnIndex)), varcharWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.CLOB:
        case OracleTypes.NCLOB:
            return Optional.of(ColumnMapping.sliceMapping(createUnboundedVarcharType(), (resultSet, columnIndex) -> utf8Slice(resultSet.getString(columnIndex)), varcharWriteFunction(), DISABLE_PUSHDOWN));
        // Oracle's RAW(n)
        case OracleTypes.VARBINARY:
        case OracleTypes.BLOB:
            return Optional.of(ColumnMapping.sliceMapping(VARBINARY, (resultSet, columnIndex) -> wrappedBuffer(resultSet.getBytes(columnIndex)), varbinaryWriteFunction(), DISABLE_PUSHDOWN));
        case OracleTypes.TIMESTAMP:
            return Optional.of(ColumnMapping.longMapping(TIMESTAMP_MILLIS, oracleTimestampReadFunction(), trinoTimestampToOracleTimestampWriteFunction(), FULL_PUSHDOWN));
        case OracleTypes.TIMESTAMPTZ:
            return Optional.of(oracleTimestampWithTimeZoneColumnMapping());
    }
    if (getUnsupportedTypeHandling(session) == CONVERT_TO_VARCHAR) {
        return mapToUnboundedVarchar(typeHandle);
    }
    return Optional.empty();
}
Also used : ZonedDateTime(java.time.ZonedDateTime) StandardColumnMappings.bigintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.bigintWriteFunction) NANOSECONDS_PER_MICROSECOND(io.trino.spi.type.Timestamps.NANOSECONDS_PER_MICROSECOND) CharType.createCharType(io.trino.spi.type.CharType.createCharType) SecureRandom(java.security.SecureRandom) Slices.wrappedBuffer(io.airlift.slice.Slices.wrappedBuffer) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) ResultSet(java.sql.ResultSet) Map(java.util.Map) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) ZoneOffset(java.time.ZoneOffset) ENGLISH(java.util.Locale.ENGLISH) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TypeHandlingJdbcSessionProperties.getUnsupportedTypeHandling(io.trino.plugin.jdbc.TypeHandlingJdbcSessionProperties.getUnsupportedTypeHandling) DateTimeEncoding.packDateTimeWithZone(io.trino.spi.type.DateTimeEncoding.packDateTimeWithZone) LongWriteFunction(io.trino.plugin.jdbc.LongWriteFunction) Set(java.util.Set) PreparedStatement(java.sql.PreparedStatement) SchemaTableName(io.trino.spi.connector.SchemaTableName) ZoneId(java.time.ZoneId) LongReadFunction(io.trino.plugin.jdbc.LongReadFunction) StandardColumnMappings.charReadFunction(io.trino.plugin.jdbc.StandardColumnMappings.charReadFunction) StandardColumnMappings.smallintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.smallintWriteFunction) StandardColumnMappings.longDecimalWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.longDecimalWriteFunction) ConnectionFactory(io.trino.plugin.jdbc.ConnectionFactory) CONVERT_TO_VARCHAR(io.trino.plugin.jdbc.UnsupportedTypeHandling.CONVERT_TO_VARCHAR) DoubleWriteFunction(io.trino.plugin.jdbc.DoubleWriteFunction) DateTimeEncoding.unpackMillisUtc(io.trino.spi.type.DateTimeEncoding.unpackMillisUtc) JdbcTableHandle(io.trino.plugin.jdbc.JdbcTableHandle) DATE(io.trino.spi.type.DateType.DATE) REAL(io.trino.spi.type.RealType.REAL) JoinCondition(io.trino.spi.connector.JoinCondition) TIMESTAMP_MILLIS(io.trino.spi.type.TimestampType.TIMESTAMP_MILLIS) LocalDateTime(java.time.LocalDateTime) BOOLEAN(io.trino.spi.type.BooleanType.BOOLEAN) Float.floatToRawIntBits(java.lang.Float.floatToRawIntBits) SQLException(java.sql.SQLException) TIMESTAMP_TZ_MILLIS(io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MILLIS) FULL_PUSHDOWN(io.trino.plugin.jdbc.PredicatePushdownController.FULL_PUSHDOWN) StandardColumnMappings.charWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.charWriteFunction) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) Math.floorDiv(java.lang.Math.floorDiv) TIMESTAMP_SECONDS(io.trino.spi.type.TimestampType.TIMESTAMP_SECONDS) DecimalType.createDecimalType(io.trino.spi.type.DecimalType.createDecimalType) QueryBuilder(io.trino.plugin.jdbc.QueryBuilder) ConnectorSession(io.trino.spi.connector.ConnectorSession) DOUBLE(io.trino.spi.type.DoubleType.DOUBLE) IdentifierMapping(io.trino.plugin.jdbc.mapping.IdentifierMapping) CharType(io.trino.spi.type.CharType) TINYINT(io.trino.spi.type.TinyintType.TINYINT) StandardColumnMappings.shortDecimalWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.shortDecimalWriteFunction) StandardColumnMappings.varbinaryWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.varbinaryWriteFunction) VarcharType.createVarcharType(io.trino.spi.type.VarcharType.createVarcharType) WriteMapping(io.trino.plugin.jdbc.WriteMapping) JDBC_ERROR(io.trino.plugin.jdbc.JdbcErrorCode.JDBC_ERROR) BaseJdbcConfig(io.trino.plugin.jdbc.BaseJdbcConfig) Connection(java.sql.Connection) MICROSECONDS_PER_MILLISECOND(io.trino.spi.type.Timestamps.MICROSECONDS_PER_MILLISECOND) OracleSessionProperties.getNumberDefaultScale(io.trino.plugin.oracle.OracleSessionProperties.getNumberDefaultScale) Math.abs(java.lang.Math.abs) DateTimeEncoding.unpackZoneKey(io.trino.spi.type.DateTimeEncoding.unpackZoneKey) ColumnMapping(io.trino.plugin.jdbc.ColumnMapping) INTEGER(io.trino.spi.type.IntegerType.INTEGER) RoundingMode(java.math.RoundingMode) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) MICROSECONDS_PER_SECOND(io.trino.spi.type.Timestamps.MICROSECONDS_PER_SECOND) TrinoException(io.trino.spi.TrinoException) Math.min(java.lang.Math.min) Instant(java.time.Instant) String.format(java.lang.String.format) List(java.util.List) JdbcTypeHandle(io.trino.plugin.jdbc.JdbcTypeHandle) StandardColumnMappings.longDecimalReadFunction(io.trino.plugin.jdbc.StandardColumnMappings.longDecimalReadFunction) BIGINT(io.trino.spi.type.BigintType.BIGINT) Decimals(io.trino.spi.type.Decimals) Optional(java.util.Optional) Math.max(java.lang.Math.max) DecimalType(io.trino.spi.type.DecimalType) OracleTypes(oracle.jdbc.OracleTypes) MAX_RADIX(java.lang.Character.MAX_RADIX) Types(java.sql.Types) SliceWriteFunction(io.trino.plugin.jdbc.SliceWriteFunction) Math.floorMod(java.lang.Math.floorMod) StandardColumnMappings.varcharWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.varcharWriteFunction) StandardColumnMappings.tinyintWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.tinyintWriteFunction) Type(io.trino.spi.type.Type) OracleSessionProperties.getNumberRoundingMode(io.trino.plugin.oracle.OracleSessionProperties.getNumberRoundingMode) VarcharType.createUnboundedVarcharType(io.trino.spi.type.VarcharType.createUnboundedVarcharType) Float.intBitsToFloat(java.lang.Float.intBitsToFloat) Inject(javax.inject.Inject) VarcharType(io.trino.spi.type.VarcharType) OraclePreparedStatement(oracle.jdbc.OraclePreparedStatement) ImmutableList(com.google.common.collect.ImmutableList) Verify.verify(com.google.common.base.Verify.verify) Objects.requireNonNull(java.util.Objects.requireNonNull) DAYS(java.util.concurrent.TimeUnit.DAYS) BaseJdbcClient(io.trino.plugin.jdbc.BaseJdbcClient) Math.toIntExact(java.lang.Math.toIntExact) JdbcJoinCondition(io.trino.plugin.jdbc.JdbcJoinCondition) JdbcColumnHandle(io.trino.plugin.jdbc.JdbcColumnHandle) StandardColumnMappings.integerWriteFunction(io.trino.plugin.jdbc.StandardColumnMappings.integerWriteFunction) DISABLE_PUSHDOWN(io.trino.plugin.jdbc.PredicatePushdownController.DISABLE_PUSHDOWN) DateTimeFormatter(java.time.format.DateTimeFormatter) StandardColumnMappings.shortDecimalReadFunction(io.trino.plugin.jdbc.StandardColumnMappings.shortDecimalReadFunction) RoundingMode(java.math.RoundingMode) OracleSessionProperties.getNumberRoundingMode(io.trino.plugin.oracle.OracleSessionProperties.getNumberRoundingMode) TrinoException(io.trino.spi.TrinoException) DecimalType.createDecimalType(io.trino.spi.type.DecimalType.createDecimalType) DecimalType(io.trino.spi.type.DecimalType) CharType.createCharType(io.trino.spi.type.CharType.createCharType) CharType(io.trino.spi.type.CharType) ColumnMapping(io.trino.plugin.jdbc.ColumnMapping)

Aggregations

BIGINT (io.trino.spi.type.BigintType.BIGINT)9 BOOLEAN (io.trino.spi.type.BooleanType.BOOLEAN)9 DOUBLE (io.trino.spi.type.DoubleType.DOUBLE)9 INTEGER (io.trino.spi.type.IntegerType.INTEGER)9 SMALLINT (io.trino.spi.type.SmallintType.SMALLINT)9 TINYINT (io.trino.spi.type.TinyintType.TINYINT)9 Type (io.trino.spi.type.Type)9 List (java.util.List)9 ImmutableList (com.google.common.collect.ImmutableList)8 DecimalType (io.trino.spi.type.DecimalType)8 REAL (io.trino.spi.type.RealType.REAL)8 VarcharType (io.trino.spi.type.VarcharType)8 Optional (java.util.Optional)8 DATE (io.trino.spi.type.DateType.DATE)7 Map (java.util.Map)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 Slice (io.airlift.slice.Slice)6 CharType (io.trino.spi.type.CharType)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Decimals (io.trino.spi.type.Decimals)5