Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
return createColumnVector(typeInfo, DataTypePhysicalVariation.NONE);
}

public static ColumnVector createColumnVector(TypeInfo typeInfo,

Check warning on line 132 in ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedBatchUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 86 to 64, Complexity from 28 to 14, Nesting Level from 3 to 2, Number of Variables from 14 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuRXucyJk4EglWW0&open=AZ90xuRXucyJk4EglWW0&pullRequest=6578
DataTypePhysicalVariation dataTypePhysicalVariation) {
switch(typeInfo.getCategory()) {
case PRIMITIVE:
Expand All @@ -146,6 +146,7 @@
case DATE:
return new DateColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
case TIMESTAMP:
case TIMESTAMPLOCALTZ:

Check warning on line 149 in ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedBatchUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 8, expected level should be 6.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuRXucyJk4EglWW3&open=AZ90xuRXucyJk4EglWW3&pullRequest=6578

Check warning on line 149 in ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedBatchUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge the previous cases into this one using comma-separated label.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuRXucyJk4EglWWz&open=AZ90xuRXucyJk4EglWWz&pullRequest=6578
return new TimestampColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
case INTERVAL_DAY_TIME:
return new IntervalDayTimeColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
Expand Down Expand Up @@ -294,7 +295,7 @@
}
}

private static void setVector(Object row,

Check warning on line 298 in ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedBatchUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 220 to 64, Complexity from 34 to 14, Nesting Level from 3 to 2, Number of Variables from 50 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuRXucyJk4EglWW1&open=AZ90xuRXucyJk4EglWW1&pullRequest=6578
StructObjectInspector oi,
StructField field,
VectorizedRowBatch batch,
Expand Down Expand Up @@ -643,7 +644,7 @@
copyNonSelectedColumnVector(sourceBatch, sourceColumnNum, targetBatch, targetColumnNum, size, 0);
}

public static void copyNonSelectedColumnVector(

Check warning on line 647 in ql/src/java/org/apache/hadoop/hive/ql/exec/vector/VectorizedBatchUtil.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

A "Brain Method" was detected. Refactor it to reduce at least one of the following metrics: LOC from 137 to 64, Complexity from 32 to 14, Nesting Level from 4 to 2, Number of Variables from 40 to 6.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuRXucyJk4EglWW2&open=AZ90xuRXucyJk4EglWW2&pullRequest=6578
VectorizedRowBatch sourceBatch, int sourceColumnNum,
VectorizedRowBatch targetBatch, int targetColumnNum,
int size, int startIndex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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

Check warning on line 10 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/ParquetTypeUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Line does not match expected header line of ' * http://www.apache.org/licenses/LICENSE-2.0'.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufeucyJk4EglWXQ&open=AZ90xufeucyJk4EglWXQ&pullRequest=6578
*
* 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.
*/
package org.apache.hadoop.hive.ql.io.parquet;

import org.apache.hadoop.hive.common.type.Date;
import org.apache.hadoop.hive.common.type.Timestamp;
import org.apache.hadoop.hive.common.type.TimestampTZ;
import org.apache.hadoop.hive.common.type.TimestampTZUtil;
import java.nio.charset.StandardCharsets;
import java.time.ZoneId;

import java.util.function.Function;

public class ParquetTypeUtils {

Check warning on line 30 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/ParquetTypeUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a private constructor to hide the implicit public one.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufeucyJk4EglWXP&open=AZ90xufeucyJk4EglWXP&pullRequest=6578

Check warning on line 30 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/ParquetTypeUtils.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Utility classes should not have a public or default constructor.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufeucyJk4EglWXR&open=AZ90xufeucyJk4EglWXR&pullRequest=6578

private static <T> T parseString(byte[] bytes, Function<String, T> parser) {
if (bytes == null || bytes.length < 8) {
return null;
}
try {
String s = new String(bytes, StandardCharsets.UTF_8);
return parser.apply(s);
} catch (Exception e) {
return null;
}
}

public static Date parseDate(byte[] bytes) {
return parseString(bytes, Date::valueOf);
}

public static Timestamp parseTimestamp(byte[] bytes) {
return parseString(bytes, Timestamp::valueOf);
}

public static TimestampTZ parseTimestampTZ(byte[] bytes, ZoneId defaultTimeZone) {
return parseString(bytes, s -> TimestampTZUtil.parse(s, defaultTimeZone));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import java.util.TimeZone;

import com.google.common.base.MoreObjects;
import org.apache.hadoop.hive.common.type.Date;
import org.apache.hadoop.hive.common.type.HiveDecimal;
import org.apache.hadoop.hive.common.type.Timestamp;
import org.apache.hadoop.hive.common.type.TimestampTZ;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.io.parquet.read.DataWritableReadSupport;
import org.apache.hadoop.hive.ql.io.parquet.timestamp.NanoTime;
Expand All @@ -40,6 +42,8 @@
import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
import org.apache.hadoop.hive.serde2.io.HiveVarcharWritable;
import org.apache.hadoop.hive.serde2.io.TimestampWritableV2;
import org.apache.hadoop.hive.serde2.io.TimestampLocalTZWritable;
import org.apache.hadoop.hive.ql.io.parquet.ParquetTypeUtils;
import org.apache.hadoop.hive.serde2.typeinfo.CharTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.DecimalTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.HiveDecimalUtils;
Expand Down Expand Up @@ -508,8 +512,7 @@
// of code paths that do not provide the typeInfo in those cases we default to Text. This idiom is also
// followed by for example the BigDecimal converter in which if there is no type information,
// it defaults to the widest representation
if (hiveTypeInfo instanceof PrimitiveTypeInfo) {
PrimitiveTypeInfo t = (PrimitiveTypeInfo) hiveTypeInfo;
if (hiveTypeInfo instanceof PrimitiveTypeInfo t) {
switch (t.getPrimitiveCategory()) {
case CHAR:
return new BinaryConverter<HiveCharWritable>(type, parent, index) {
Expand All @@ -525,9 +528,33 @@
return new HiveVarcharWritable(binary.getBytes(), ((VarcharTypeInfo) hiveTypeInfo).getLength());
}
};
case DATE:

Check warning on line 531 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 10, expected level should be 8.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ8pVx0N3-Z9uIIJayj6&open=AZ8pVx0N3-Z9uIIJayj6&pullRequest=6578
return new BinaryConverter<DateWritableV2>(type, parent, index) {

Check warning on line 532 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'block' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ8pVx0N3-Z9uIIJayj7&open=AZ8pVx0N3-Z9uIIJayj7&pullRequest=6578
@Override
protected DateWritableV2 convert(Binary binary) {
Date date = ParquetTypeUtils.parseDate(binary.getBytes());
return date != null ? new DateWritableV2(date) : null;
}
};
case TIMESTAMP:

Check warning on line 539 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 10, expected level should be 8.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufTucyJk4EglWXL&open=AZ90xufTucyJk4EglWXL&pullRequest=6578
return new BinaryConverter<TimestampWritableV2>(type, parent, index) {

Check warning on line 540 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'block' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufTucyJk4EglWXM&open=AZ90xufTucyJk4EglWXM&pullRequest=6578
@Override
protected TimestampWritableV2 convert(Binary binary) {
Timestamp ts = ParquetTypeUtils.parseTimestamp(binary.getBytes());
return ts != null ? new TimestampWritableV2(ts) : null;
}
};
case TIMESTAMPLOCALTZ:

Check warning on line 547 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 10, expected level should be 8.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufTucyJk4EglWXN&open=AZ90xufTucyJk4EglWXN&pullRequest=6578
return new BinaryConverter<TimestampLocalTZWritable>(type, parent, index) {

Check warning on line 548 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'block' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xufTucyJk4EglWXO&open=AZ90xufTucyJk4EglWXO&pullRequest=6578
@Override
protected TimestampLocalTZWritable convert(Binary binary) {
TimestampTZ tstz = ParquetTypeUtils.parseTimestampTZ(binary.getBytes(), ZoneId.systemDefault());
return tstz != null ? new TimestampLocalTZWritable(tstz) : null;
}
};
}
}
// STRING type
// Default to STRING type (Text)
return new BinaryConverter<Text>(type, parent, index) {
@Override
protected Text convert(Binary binary) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.MapTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TimestampLocalTZTypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo;
Expand Down Expand Up @@ -137,6 +138,8 @@
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector((CharTypeInfo) typeInfo);
} else if (typeInfo.getTypeName().toLowerCase().startsWith(serdeConstants.VARCHAR_TYPE_NAME)) {
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector((VarcharTypeInfo) typeInfo);
} else if (typeInfo instanceof TimestampLocalTZTypeInfo) {

Check warning on line 141 in ql/src/java/org/apache/hadoop/hive/ql/io/parquet/serde/ArrayWritableObjectInspector.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace this instanceof check and cast with 'instanceof TimestampLocalTZTypeInfo timestamplocaltztypeinfo'

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AZ90xuc8ucyJk4EglWW4&open=AZ90xuc8ucyJk4EglWW4&pullRequest=6578
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector((TimestampLocalTZTypeInfo) typeInfo);
} else {
throw new UnsupportedOperationException("Unknown field type: " + typeInfo);
}
Expand Down
Loading
Loading