You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/27 18:11:22 UTC
[GitHub] [arrow] emkornfield opened a new pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
emkornfield opened a new pull request #10177:
URL: https://github.com/apache/arrow/pull/10177
Trying to formalize mailing list discussion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696007626
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
I thought I did (ping you on the lines added to random_test.cc, if that is insufficient, please let me know).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690515104
##########
File path: cpp/src/arrow/type.h
##########
@@ -1317,6 +1317,40 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType {
std::string name() const override { return "day_time_interval"; }
};
+/// \brief Represents a number of days and milliseconds (fraction of day).
+class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType {
+ public:
+ struct MonthDayNanos {
+ int32_t months;
+ int32_t days;
+ int64_t nanoseconds;
+ bool operator==(MonthDayNanos other) const {
+ return this->months == other.months && this->days == other.days &&
+ this->nanoseconds == other.nanoseconds;
+ }
+ bool operator!=(MonthDayNanos other) const { return !(*this == other); }
+ };
+ using c_type = MonthDayNanos;
+ using PhysicalType = MonthDayNanoIntervalType;
+
+ static_assert(sizeof(MonthDayNanos) == 16,
+ "MonthDayNanos struct assumed to be of size 8 bytes");
Review comment:
done.
##########
File path: cpp/src/arrow/array/array_primitive.h
##########
@@ -132,4 +136,33 @@ class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray {
const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); }
};
+/// \brief Array of Month, Day and nanosecond values.
+class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray {
+ public:
+ using TypeClass = MonthDayNanoIntervalType;
+
+ explicit MonthDayNanoIntervalArray(const std::shared_ptr<ArrayData>& data);
+
+ MonthDayNanoIntervalArray(const std::shared_ptr<DataType>& type, int64_t length,
+ const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ MonthDayNanoIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ TypeClass::MonthDayNanos GetValue(int64_t i) const;
+ TypeClass::MonthDayNanos Value(int64_t i) const { return GetValue(i); }
+
+ // For compatibility with Take kernel.
+ TypeClass::MonthDayNanos GetView(int64_t i) const { return GetValue(i); }
+
+ int32_t byte_width() const { return sizeof(TypeClass::MonthDayNanos); }
+ static_assert(sizeof(TypeClass::MonthDayNanos) == 16,
+ "MonthDayNanos should only take 16 bytes");
Review comment:
removed.
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -1332,12 +1366,16 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesLazyIter) {
}
TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesIterConverted) {
- DECL_T();
+ typedef typename TestFixture::CType T;
// find type we can safely convert the tested values to and from
- using conversion_type =
- typename std::conditional<std::is_floating_point<T>::value, double,
- typename std::conditional<std::is_unsigned<T>::value,
- uint64_t, int64_t>::type>::type;
+ using conversion_type = typename std::conditional<
+ std::is_floating_point<T>::value, double,
+ typename std::conditional<
+ std::is_same<T, DayTimeIntervalType::DayMilliseconds>::value ||
+ std::is_same<T, MonthDayNanoIntervalType::MonthDayNanos>::value,
+ T,
+ typename std::conditional<std::is_unsigned<T>::value, uint64_t,
+ int64_t>::type>::type>::type;
Review comment:
done.
##########
File path: cpp/src/arrow/ipc/json_simple.cc
##########
@@ -410,6 +410,41 @@ class DayTimeIntervalConverter final
std::shared_ptr<DayTimeIntervalBuilder> builder_;
};
+class MonthDayNanoIntervalConverter final
+ : public ConcreteConverter<MonthDayNanoIntervalConverter> {
+ public:
+ explicit MonthDayNanoIntervalConverter(const std::shared_ptr<DataType>& type) {
+ this->type_ = type;
+ builder_ = std::make_shared<MonthDayNanoIntervalBuilder>(default_memory_pool());
+ }
+
+ Status AppendValue(const rj::Value& json_obj) override {
+ if (json_obj.IsNull()) {
+ return this->AppendNull();
+ }
+ MonthDayNanoIntervalType::MonthDayNanos value;
+ if (!json_obj.IsArray()) {
+ return JSONTypeError("array", json_obj.GetType());
+ }
+ if (json_obj.Size() != 3) {
+ return Status::Invalid(
+ "month day nanos interval pair must have exactly two elements, had ",
Review comment:
sorry, fixed.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
should be done.
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
Review comment:
This unfortunately is a pattern established for integration testing which lives in a separate package.
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getMonths(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH);
+ }
+
+
+ /**
+ * Given a data buffer, get the number of days stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getDays(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH + DAY_OFFSET);
+ }
+
+ /**
+ * Given a data buffer, get the get the number of nanoseconds stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return nanoseconds value stored at the index.
+ */
+ public static long getNanoseconds(final ArrowBuf buffer, final int index) {
+ return buffer.getLong((long) index * TYPE_WIDTH + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Get the element at the given index from the vector.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public ArrowBuf get(int index) throws IllegalStateException {
+ if (NULL_CHECKING_ENABLED && isSet(index) == 0) {
+ return null;
+ }
+ return valueBuffer.slice((long) index * TYPE_WIDTH, TYPE_WIDTH);
+ }
+
+ /**
+ * Get the element at the given index from the vector and
+ * sets the state in holder. If element at given index
+ * is null, holder.isSet will be zero.
+ *
+ * @param index position of element
+ */
+ public void get(int index, NullableIntervalMonthDayNanoHolder holder) {
+ if (isSet(index) == 0) {
+ holder.isSet = 0;
+ return;
+ }
+ final long startIndex = (long) index * TYPE_WIDTH;
+ holder.isSet = 1;
+ holder.months = valueBuffer.getInt(startIndex);
+ holder.days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ holder.nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Same as {@link #get(int)}.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public PeriodDuration getObject(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ final long startIndex = (long) index * TYPE_WIDTH;
+ final int months = valueBuffer.getInt(startIndex);
+ final int days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ final long nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+
+ return new PeriodDuration(Period.ofMonths(months).plusDays(days),
+ Duration.ofNanos(nanoseconds));
+ }
+ }
+
+ /**
+ * Get the Interval value at a given index as a {@link StringBuilder} object.
+ *
+ * @param index position of the element
+ * @return String Builder object with Interval value as
+ */
+ public StringBuilder getAsStringBuilder(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ return getAsStringBuilderHelper(index);
+ }
+ }
+
+ private StringBuilder getAsStringBuilderHelper(int index) {
+ final long startIndex = (long) index * TYPE_WIDTH;
Review comment:
nice catch.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
sorry still need to add a test.
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/PeriodDuration.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import java.time.Duration;
+import java.time.Period;
+
+/**
+ * Combination of Period and Duration for representing this interval type
+ * as a POJO.
+ */
+public class PeriodDuration {
+ private final Period period;
+ private final Duration duration;
+
+ public PeriodDuration(Period period, Duration duration) {
+ this.period = period;
+ this.duration = duration;
+ }
+
+ public Period getPeriod() {
+ return period;
+ }
+
+ public Duration getDuration() {
+ return duration;
+ }
+
+ @Override
+ public String toString() {
+ return period.toString() + " " + duration.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof PeriodDuration)) {
+ return false;
+ }
+ PeriodDuration other = (PeriodDuration) o;
+ return this.period.equals(other.period) && this.duration.equals(other.duration);
Review comment:
no .added check not null.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689227995
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
Review comment:
nit: a space is missed here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r687235420
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantitiy of nanoseconds represents less
Review comment:
done.
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
Review comment:
done.
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantitiy of nanoseconds represents less
+// then a day's worth of time).
Review comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] alamb commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-828337316
@ovr and @nevi-me I wonder if you have any thoughts / opinions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r622083429
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
Review comment:
It would be nice to indicate that for all three interval types indeed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-828552989
> I know I was lobbying for nanosecond precision intervals, but given postgres and parquet both use millisecond precision, perhaps it would be best if Arrow followed the same model?
I thought postgres used Microseconds not Milliseconds. This is why the postgres struct there was 8 bytes for seconds/subseconds. I actually liked the argument for having the finest grained available data available of other Arrow temporal types. I'm not sure any alignment is going to be perfect. Using this type in language specific concepts is already going to require a special type (e.g. there is nothing that seems to include all the fields together in the survey).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-908866344
Thanks for the reviews. merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-901673480
> @liyafan82 @pitrou thank you for the reviews, I think I addressed the relevant comments.
Thanks for your update.
Had another pass today. Mostly looks good to me, with one additional minor comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-900616476
@liyafan82 @pitrou thank you for the reviews, I think I addressed the relevant comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696001673
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3060,4 +3098,14 @@ TEST(TestSwapEndianArrayData, ExtensionType) {
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}
+TEST(TestSwapEndianArrayData, MonthDayNanoInterval) {
+ auto array = ArrayFromJSON(month_day_nano_interval(), R"([[0, 1, 2],
+ [5000, 200, 3000000000]])");
+ auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(array->data()));
+ EXPECT_TRUE(!swap_array->Equals(array));
+ ASSERT_ARRAYS_EQUAL(
+ *MakeArray(*::arrow::internal::SwapEndianArrayData(swap_array->data())), *array);
+ ASSERT_OK(swap_array->ValidateFull());
+}
Review comment:
Gentle ping here :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-906025236
The Java changes LGTM. Good job! @emkornfield
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689229653
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
Review comment:
If it is not intended to be used externally, then it should not be declared "public"?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] quinnj commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
quinnj commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r624747797
##########
File path: format/Schema.fbs
##########
@@ -17,6 +17,11 @@
/// Logical types, vector layouts, and schemas
+/// Format Version History.
+/// Version 1.0 - Forward and backwards compability guaranteed.
+/// Version 1.1 - Add Decimal256 (No format release).
+/// Version 1.2 (Pending)- Add Interal DAY_TIME_NANO
Review comment:
```suggestion
/// Version 1.2 (Pending)- Add Interval DAY_TIME_NANO
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696014979
##########
File path: cpp/src/arrow/testing/random_test.cc
##########
@@ -108,8 +108,9 @@ auto values = ::testing::Values(
field("time32ms", time32(TimeUnit::MILLI)), field("time64ns", time64(TimeUnit::NANO)),
field("time32s", time32(TimeUnit::SECOND)),
field("time64us", time64(TimeUnit::MICRO)), field("month_interval", month_interval()),
- field("daytime_interval", day_time_interval()), field("listint8", list(int8())),
- field("listlistint8", list(list(int8()))),
+ field("daytime_interval", day_time_interval()),
Review comment:
Ah, right, thank you. I had missed this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] alamb commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r688913337
##########
File path: format/Schema.fbs
##########
@@ -269,15 +274,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of the number of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantity of nanoseconds represents less
+// than a day's worth of time).
Review comment:
I was rereading this and I noticed that `DAY_TIME` says:
> Support of this IntervalUnit is not required for full arrow compatibility.
I wonder if the same caveat is meant to apply to `MONTH_DAY_NANO`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690522705
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getMonths(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH);
+ }
+
+
+ /**
+ * Given a data buffer, get the number of days stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getDays(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH + DAY_OFFSET);
+ }
+
+ /**
+ * Given a data buffer, get the get the number of nanoseconds stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return nanoseconds value stored at the index.
+ */
+ public static long getNanoseconds(final ArrowBuf buffer, final int index) {
+ return buffer.getLong((long) index * TYPE_WIDTH + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Get the element at the given index from the vector.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public ArrowBuf get(int index) throws IllegalStateException {
+ if (NULL_CHECKING_ENABLED && isSet(index) == 0) {
+ return null;
+ }
+ return valueBuffer.slice((long) index * TYPE_WIDTH, TYPE_WIDTH);
+ }
+
+ /**
+ * Get the element at the given index from the vector and
+ * sets the state in holder. If element at given index
+ * is null, holder.isSet will be zero.
+ *
+ * @param index position of element
+ */
+ public void get(int index, NullableIntervalMonthDayNanoHolder holder) {
+ if (isSet(index) == 0) {
+ holder.isSet = 0;
+ return;
+ }
+ final long startIndex = (long) index * TYPE_WIDTH;
+ holder.isSet = 1;
+ holder.months = valueBuffer.getInt(startIndex);
+ holder.days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ holder.nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Same as {@link #get(int)}.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public PeriodDuration getObject(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ final long startIndex = (long) index * TYPE_WIDTH;
+ final int months = valueBuffer.getInt(startIndex);
+ final int days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ final long nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+
+ return new PeriodDuration(Period.ofMonths(months).plusDays(days),
+ Duration.ofNanos(nanoseconds));
+ }
+ }
+
+ /**
+ * Get the Interval value at a given index as a {@link StringBuilder} object.
+ *
+ * @param index position of the element
+ * @return String Builder object with Interval value as
+ */
+ public StringBuilder getAsStringBuilder(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ return getAsStringBuilderHelper(index);
+ }
+ }
+
+ private StringBuilder getAsStringBuilderHelper(int index) {
+ final long startIndex = (long) index * TYPE_WIDTH;
Review comment:
nice catch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorisvandenbossche commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-831123392
The Parquet reference includes this paragraph:
> Each component in this representation is independent of the others. For example, there is no requirement that a large number of days should be expressed as a mix of months and days because there is not a constant conversion from days to months.
Should something similar be added to clarify that eg the nanoseconds field is not limited to 1 day?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r621931630
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
Review comment:
Also, is it `MONTH_DAY_NANO` or `MONTH_DAY_NANOS` ? Seems like it should be the former.
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
Review comment:
And "elapsed" :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorgecarleitao commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-898929295
1. Should we also declare the format on the c data interface?
We currently have:
* `tiM` - interval [months]
* `tiD` - interval [days, time]
maybe `tiN` (Nano seems to be the only thing that is different from the existing ones)?
2. it seems that we usually generate files and place them on the testing git repo so that users do not need to compile all other languages and use docker to test against the IPC files and streams. I do not know which script we use, but it could be useful to have them also.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] wesm commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
wesm commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r621730478
##########
File path: format/Schema.fbs
##########
@@ -255,6 +255,10 @@ enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of (# of months, # of days, # nanoseconds).
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer.
Review comment:
Indicate endianness (this should be done for the other unit types too)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorgecarleitao commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r622046601
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
Review comment:
do we need to specify if these are signed or unsigned integers?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690515104
##########
File path: cpp/src/arrow/type.h
##########
@@ -1317,6 +1317,40 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType {
std::string name() const override { return "day_time_interval"; }
};
+/// \brief Represents a number of days and milliseconds (fraction of day).
+class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType {
+ public:
+ struct MonthDayNanos {
+ int32_t months;
+ int32_t days;
+ int64_t nanoseconds;
+ bool operator==(MonthDayNanos other) const {
+ return this->months == other.months && this->days == other.days &&
+ this->nanoseconds == other.nanoseconds;
+ }
+ bool operator!=(MonthDayNanos other) const { return !(*this == other); }
+ };
+ using c_type = MonthDayNanos;
+ using PhysicalType = MonthDayNanoIntervalType;
+
+ static_assert(sizeof(MonthDayNanos) == 16,
+ "MonthDayNanos struct assumed to be of size 8 bytes");
Review comment:
done.
##########
File path: cpp/src/arrow/array/array_primitive.h
##########
@@ -132,4 +136,33 @@ class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray {
const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); }
};
+/// \brief Array of Month, Day and nanosecond values.
+class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray {
+ public:
+ using TypeClass = MonthDayNanoIntervalType;
+
+ explicit MonthDayNanoIntervalArray(const std::shared_ptr<ArrayData>& data);
+
+ MonthDayNanoIntervalArray(const std::shared_ptr<DataType>& type, int64_t length,
+ const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ MonthDayNanoIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ TypeClass::MonthDayNanos GetValue(int64_t i) const;
+ TypeClass::MonthDayNanos Value(int64_t i) const { return GetValue(i); }
+
+ // For compatibility with Take kernel.
+ TypeClass::MonthDayNanos GetView(int64_t i) const { return GetValue(i); }
+
+ int32_t byte_width() const { return sizeof(TypeClass::MonthDayNanos); }
+ static_assert(sizeof(TypeClass::MonthDayNanos) == 16,
+ "MonthDayNanos should only take 16 bytes");
Review comment:
removed.
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -1332,12 +1366,16 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesLazyIter) {
}
TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesIterConverted) {
- DECL_T();
+ typedef typename TestFixture::CType T;
// find type we can safely convert the tested values to and from
- using conversion_type =
- typename std::conditional<std::is_floating_point<T>::value, double,
- typename std::conditional<std::is_unsigned<T>::value,
- uint64_t, int64_t>::type>::type;
+ using conversion_type = typename std::conditional<
+ std::is_floating_point<T>::value, double,
+ typename std::conditional<
+ std::is_same<T, DayTimeIntervalType::DayMilliseconds>::value ||
+ std::is_same<T, MonthDayNanoIntervalType::MonthDayNanos>::value,
+ T,
+ typename std::conditional<std::is_unsigned<T>::value, uint64_t,
+ int64_t>::type>::type>::type;
Review comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689237349
##########
File path: java/vector/src/test/java/org/apache/arrow/vector/TestIntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.junit.Assert.assertEquals;
+
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestIntervalMonthDayNanoVector {
+
+ private BufferAllocator allocator;
+
+ @Before
+ public void init() {
+ allocator = new DirtyRootAllocator(Long.MAX_VALUE, (byte) 100);
+ }
+
+ @After
+ public void terminate() throws Exception {
+ allocator.close();
+ }
+
+ @Test
+ public void testBasics() {
+ try (final IntervalMonthDayNanoVector vector = new IntervalMonthDayNanoVector(/*name=*/"", allocator)) {
+ int valueCount = 100;
+ vector.setInitialCapacity(valueCount);
+ vector.allocateNew();
+ NullableIntervalMonthDayNanoHolder nullableHolder = new NullableIntervalMonthDayNanoHolder();
+ nullableHolder.isSet = 1;
+ nullableHolder.months = 2;
+ nullableHolder.days = 20;
+ nullableHolder.nanoseconds = 123;
+ IntervalMonthDayNanoHolder holder = new IntervalMonthDayNanoHolder();
+ holder.months = Integer.MIN_VALUE;
+ holder.days = Integer.MIN_VALUE;
+ holder.nanoseconds = Long.MIN_VALUE;
+
+
+ vector.set(0, /*moths=*/1, /*days=*/2, /*nanoseconds=*/-2);
+ vector.setSafe(2, /*moths=*/1, /*days=*/2, /*nanoseconds=*/-3);
+ vector.setSafe(/*index=*/4, nullableHolder);
+ vector.set(3, holder);
+ nullableHolder.isSet = 0;
+ vector.setSafe(/*index=*/5, nullableHolder);
Review comment:
nit: we should `setValueCount` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-896318103
@pitrou I pushed basic support for C++ (going to start working on java and integration tests now). I imagine CI could complain especially MSVC, will fix that once I have results.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696015918
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3060,4 +3098,14 @@ TEST(TestSwapEndianArrayData, ExtensionType) {
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}
+TEST(TestSwapEndianArrayData, MonthDayNanoInterval) {
+ auto array = ArrayFromJSON(month_day_nano_interval(), R"([[0, 1, 2],
+ [5000, 200, 3000000000]])");
+ auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(array->data()));
+ EXPECT_TRUE(!swap_array->Equals(array));
+ ASSERT_ARRAYS_EQUAL(
+ *MakeArray(*::arrow::internal::SwapEndianArrayData(swap_array->data())), *array);
+ ASSERT_OK(swap_array->ValidateFull());
+}
Review comment:
Uh, for some reason, Github wasn't showing the right changeset. Sorry for this :-(
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696002224
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
Still need to add a test here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689232109
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getMonths(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH);
+ }
+
+
+ /**
+ * Given a data buffer, get the number of days stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getDays(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH + DAY_OFFSET);
+ }
+
+ /**
+ * Given a data buffer, get the get the number of nanoseconds stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return nanoseconds value stored at the index.
+ */
+ public static long getNanoseconds(final ArrowBuf buffer, final int index) {
+ return buffer.getLong((long) index * TYPE_WIDTH + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Get the element at the given index from the vector.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public ArrowBuf get(int index) throws IllegalStateException {
+ if (NULL_CHECKING_ENABLED && isSet(index) == 0) {
+ return null;
+ }
+ return valueBuffer.slice((long) index * TYPE_WIDTH, TYPE_WIDTH);
+ }
+
+ /**
+ * Get the element at the given index from the vector and
+ * sets the state in holder. If element at given index
+ * is null, holder.isSet will be zero.
+ *
+ * @param index position of element
+ */
+ public void get(int index, NullableIntervalMonthDayNanoHolder holder) {
+ if (isSet(index) == 0) {
+ holder.isSet = 0;
+ return;
+ }
+ final long startIndex = (long) index * TYPE_WIDTH;
+ holder.isSet = 1;
+ holder.months = valueBuffer.getInt(startIndex);
+ holder.days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ holder.nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Same as {@link #get(int)}.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public PeriodDuration getObject(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ final long startIndex = (long) index * TYPE_WIDTH;
+ final int months = valueBuffer.getInt(startIndex);
+ final int days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ final long nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+
+ return new PeriodDuration(Period.ofMonths(months).plusDays(days),
+ Duration.ofNanos(nanoseconds));
+ }
+ }
+
+ /**
+ * Get the Interval value at a given index as a {@link StringBuilder} object.
+ *
+ * @param index position of the element
+ * @return String Builder object with Interval value as
+ */
+ public StringBuilder getAsStringBuilder(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ return getAsStringBuilderHelper(index);
+ }
+ }
+
+ private StringBuilder getAsStringBuilderHelper(int index) {
+ final long startIndex = (long) index * TYPE_WIDTH;
+ return new StringBuilder().append(getObject(index).toString()).append(" ");
+ }
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value setter methods |
+ | |
+ *----------------------------------------------------------------*/
+
+
+ /**
+ * Set the element at the given index to the given value.
+ *
+ * @param index position of element
+ * @param value value of element
+ */
+ public void set(int index, ArrowBuf value) {
+ BitVectorHelper.setBit(validityBuffer, index);
+ valueBuffer.setBytes((long) index * TYPE_WIDTH, value, 0, TYPE_WIDTH);
+ }
+
+ /**
+ * Set the element at the given index to the given value.
+ *
+ * @param index position of element
+ * @param months months component of interval
+ * @param days days component of interval
+ * @param nanoseconds nanosecond component of interval
+ */
+ public void set(int index, int months, int days, long nanoseconds) {
+ final long offsetIndex = (long) index * TYPE_WIDTH;
+ BitVectorHelper.setBit(validityBuffer, index);
+ valueBuffer.setInt(offsetIndex, months);
+ valueBuffer.setInt(offsetIndex + DAY_OFFSET, days);
+ valueBuffer.setLong((offsetIndex + NANOSECOND_OFFSET), nanoseconds);
+ }
+
+ /**
+ * Set the element at the given index to the value set in data holder.
+ * If the value in holder is not indicated as set, element in the
Review comment:
remove 'in the'?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690515688
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
should be done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-898811945
https://issues.apache.org/jira/browse/ARROW-13628
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r688967515
##########
File path: java/format/src/main/java/org/apache/arrow/flatbuf/Timestamp.java
##########
@@ -29,8 +29,33 @@
* leap seconds, as a 64-bit integer. Note that UNIX time does not include
* leap seconds.
*
- * The Timestamp metadata supports both "time zone naive" and "time zone
- * aware" timestamps. Read about the timezone attribute for more detail
+ * Date & time libraries often have multiple different data types for temporal
+ * data. In order to ease interoperability between different implementations the
+ * Arrow project has some recommendations for encoding these types into a Timestamp
+ * column.
+ *
+ * An "instant" represents a single moment in time that has no meaningful time zone
+ * or the time zone is unknown. A column of instants can also contain values from
+ * multiple time zones. To encode an instant set the timezone string to "UTC".
+ *
+ * A "zoned date-time" represents a single moment in time that has a meaningful
+ * reference time zone. To encode a zoned date-time as a Timestamp set the timezone
+ * string to the name of the timezone. There is some ambiguity between an instant
+ * and a zoned date-time with the UTC time zone. Both of these are stored the same.
+ * Typically, this distinction does not matter. If it does, then an application should
Review comment:
this is just updating generated code from FBS :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-898811967
OK, I think I'm done with the initial batch of changes.
@pitrou or @bkietz would you mind reviewing C++
@liyafan82 could you review Java.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield edited a comment on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield edited a comment on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-897330799
@bkietz curious if you have any thoughts on how I might fix the MSVC error, I'm not sure why the gtest is getting confused.
It appears b5fd2a3 fixed the issue. Not sure why primitives vs structs would affect MSVC type resolution here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] westonpace commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
westonpace commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-828853214
I believe this would also imply a minor bump to the Arrow columnar format version? (1.0.0 -> 1.1.0)? From a quick glance it seems forwards compatibility should be ok (I think you'll get `Status::NotImplemented("Unrecognized interval type.")`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-904834490
> Are the Rust integration failures expected? the CI builds are green on git master.
@jorgecarleitao [investigated](https://lists.apache.org/thread.html/r84491f36d7e36be1b2e6d21466963ae5401669e84c3a2ea9ef34de55%40%3Cdev.arrow.apache.org%3E) and did not think it was related to this change but rather a latent bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689237135
##########
File path: java/vector/src/test/java/org/apache/arrow/vector/TestIntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.junit.Assert.assertEquals;
+
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestIntervalMonthDayNanoVector {
+
+ private BufferAllocator allocator;
+
+ @Before
+ public void init() {
+ allocator = new DirtyRootAllocator(Long.MAX_VALUE, (byte) 100);
+ }
+
+ @After
+ public void terminate() throws Exception {
+ allocator.close();
+ }
+
+ @Test
+ public void testBasics() {
+ try (final IntervalMonthDayNanoVector vector = new IntervalMonthDayNanoVector(/*name=*/"", allocator)) {
+ int valueCount = 100;
+ vector.setInitialCapacity(valueCount);
+ vector.allocateNew();
+ NullableIntervalMonthDayNanoHolder nullableHolder = new NullableIntervalMonthDayNanoHolder();
+ nullableHolder.isSet = 1;
+ nullableHolder.months = 2;
+ nullableHolder.days = 20;
+ nullableHolder.nanoseconds = 123;
+ IntervalMonthDayNanoHolder holder = new IntervalMonthDayNanoHolder();
+ holder.months = Integer.MIN_VALUE;
+ holder.days = Integer.MIN_VALUE;
+ holder.nanoseconds = Long.MIN_VALUE;
+
+
+ vector.set(0, /*moths=*/1, /*days=*/2, /*nanoseconds=*/-2);
Review comment:
nit: moths -> months
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689231040
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getMonths(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH);
+ }
+
+
+ /**
+ * Given a data buffer, get the number of days stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return day value stored at the index.
+ */
+ public static int getDays(final ArrowBuf buffer, final int index) {
+ return buffer.getInt((long) index * TYPE_WIDTH + DAY_OFFSET);
+ }
+
+ /**
+ * Given a data buffer, get the get the number of nanoseconds stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
+ *
+ * @param buffer data buffer
+ * @param index position of the element.
+ * @return nanoseconds value stored at the index.
+ */
+ public static long getNanoseconds(final ArrowBuf buffer, final int index) {
+ return buffer.getLong((long) index * TYPE_WIDTH + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Get the element at the given index from the vector.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public ArrowBuf get(int index) throws IllegalStateException {
+ if (NULL_CHECKING_ENABLED && isSet(index) == 0) {
+ return null;
+ }
+ return valueBuffer.slice((long) index * TYPE_WIDTH, TYPE_WIDTH);
+ }
+
+ /**
+ * Get the element at the given index from the vector and
+ * sets the state in holder. If element at given index
+ * is null, holder.isSet will be zero.
+ *
+ * @param index position of element
+ */
+ public void get(int index, NullableIntervalMonthDayNanoHolder holder) {
+ if (isSet(index) == 0) {
+ holder.isSet = 0;
+ return;
+ }
+ final long startIndex = (long) index * TYPE_WIDTH;
+ holder.isSet = 1;
+ holder.months = valueBuffer.getInt(startIndex);
+ holder.days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ holder.nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+ }
+
+ /**
+ * Same as {@link #get(int)}.
+ *
+ * @param index position of element
+ * @return element at given index
+ */
+ public PeriodDuration getObject(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ final long startIndex = (long) index * TYPE_WIDTH;
+ final int months = valueBuffer.getInt(startIndex);
+ final int days = valueBuffer.getInt(startIndex + DAY_OFFSET);
+ final long nanoseconds = valueBuffer.getLong(startIndex + NANOSECOND_OFFSET);
+
+ return new PeriodDuration(Period.ofMonths(months).plusDays(days),
+ Duration.ofNanos(nanoseconds));
+ }
+ }
+
+ /**
+ * Get the Interval value at a given index as a {@link StringBuilder} object.
+ *
+ * @param index position of the element
+ * @return String Builder object with Interval value as
+ */
+ public StringBuilder getAsStringBuilder(int index) {
+ if (isSet(index) == 0) {
+ return null;
+ } else {
+ return getAsStringBuilderHelper(index);
+ }
+ }
+
+ private StringBuilder getAsStringBuilderHelper(int index) {
+ final long startIndex = (long) index * TYPE_WIDTH;
Review comment:
`startIndex` is not used here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r621792072
##########
File path: format/Schema.fbs
##########
@@ -255,6 +255,10 @@ enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of (# of months, # of days, # nanoseconds).
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer.
Review comment:
yes. Added a sentence at the top. I believe these all use endianness indicated by the schema.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689930031
##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_test.cc
##########
@@ -803,6 +803,24 @@ TEST_F(TestIndexInKernel, FixedSizeBinary) {
CheckIndexIn(fixed_size_binary(0), R"([])", R"([])", R"([])");
}
+TEST_F(TestIndexInKernel, MonthDayNanoInterval) {
+ auto type = month_day_nano_interval();
+
+ CheckIndexIn(type,
+ /*input=*/R"([[5, -1, 5], null, [4, 5, 6], [5, -1, 5], [1, 2, 3]])",
+ /*value_set=*/R"([null, [4, 5, 6], [5, -1, 5]])",
+ /*expected=*/R"([2, 0, 1, 2, null])",
+ /*skip_nulls=*/false);
+
+ // Duplicates in value_set
+ CheckIndexIn(
+ type,
+ /*input=*/R"([[7, 8, 0], null, [0, 0, 0], [7, 8, 0], [0, 0, 1]])",
+ /*value_set=*/R"([null, null, [0, 0, 0], [0, 0, 0], [7, 8, 0], [7, 8, 0]])",
+ /*expected=*/R"([4, 0, 2, 4, null])",
+ /*skip_nulls=*/false);
+}
+
Review comment:
I'm not really sure. I included this, because this seemed like the only code path to test the change for adding a hash for the new type. I might have been able to skip adding some of the code but it wasn't immediately obvious to me how to do that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorisvandenbossche commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-831487763
Looks good!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r622313786
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
Review comment:
So for YEAR_MONTH it is signed I believe.
The case of DAY_TIME is a little bit more ambiguous, I'm not aware of any validation we do today and here is what postgres docs say about the SQL standard.
```
According to the SQL standard all fields of an interval value must have the same sign, so a leading negative sign applies to all fields; for example the negative sign in the interval literal '-1 2:03:04' applies to both the days and hour/minute/second parts. PostgreSQL allows the fields to have different signs, and traditionally treats each field in the textual representation as independently signed, so that the hour/minute/second part is considered positive in this example. If IntervalStyle is set to sql_standard then a leading sign is considered to apply to all fields (but only if no additional signs appear). Otherwise the traditional PostgreSQL interpretation is used. To avoid ambiguity, it's recommended to attach an explicit sign to each field if any field is negative.
```
For the new type, based on the docs, I'd propose all values are signed? Sound reasonable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-828929578
> I believe this would also imply a minor bump to the Arrow columnar format version? (1.0.0 -> 1.1.0)? From a quick glance it seems forwards compatibility should be ok (I think you'll get Status::NotImplemented("Unrecognized interval type."))
Yes I added a comment above with version history. We should discuss on the ML, but I think it makes sense to release as soon as changes are accepted for the format.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689680020
##########
File path: format/Schema.fbs
##########
@@ -17,6 +17,11 @@
/// Logical types, vector layouts, and schemas
+/// Format Version History.
+/// Version 1.0 - Forward and backwards compatibility guaranteed.
+/// Version 1.1 - Add Decimal256 (No format release).
+/// Version 1.2 (Pending)- Add Interval MONTH_DAY_NANO
Review comment:
We [have](https://arrow.apache.org/docs/format/Versioning.html) this but I don't know if we've been officially announcing/voting on them as separate releases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-898930067
> Should we also declare the format on the c data interface?
I'd like to handle this in a separate PR
> it seems that we usually generate files and place them on the testing git repo so that users do not need to compile all other languages and use docker to test against the IPC files and streams. I do not know which script we use, but it could be useful to have them also.
I don't think we've been very consistent here. In the past I think we only did this when we had specific new features in the format, not necessarily new data type. @pitrou I think added the last set, maybe he can comment on why he did this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield closed pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield closed pull request #10177:
URL: https://github.com/apache/arrow/pull/10177
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-852259288
Was this voted on already? I forget.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] wesm commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
wesm commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r627538927
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantitiy of nanoseconds represents less
+// then a day's worth of time).
Review comment:
than
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantitiy of nanoseconds represents less
Review comment:
quantity
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
Review comment:
# -> number
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
Review comment:
# to number
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
Review comment:
`#` to number
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690522199
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/IntervalMonthDayNanoVector.java
##########
@@ -0,0 +1,440 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.apache.arrow.vector.NullCheckingForGet.NULL_CHECKING_ENABLED;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.apache.arrow.memory.ArrowBuf;
+import org.apache.arrow.memory.BufferAllocator;
+import org.apache.arrow.vector.complex.impl.IntervalMonthDayNanoReaderImpl;
+import org.apache.arrow.vector.complex.reader.FieldReader;
+import org.apache.arrow.vector.holders.IntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.holders.NullableIntervalMonthDayNanoHolder;
+import org.apache.arrow.vector.types.Types.MinorType;
+import org.apache.arrow.vector.types.pojo.Field;
+import org.apache.arrow.vector.types.pojo.FieldType;
+import org.apache.arrow.vector.util.TransferPair;
+
+/**
+ * IntervalMonthDayNanoVectorimplements a fixed width vector (16 bytes) of
+ * interval (month, days and nanoseconds) values which could be null.
+ * A validity buffer (bit vector) is maintained to track which elements in the
+ * vector are null.
+ */
+public final class IntervalMonthDayNanoVector extends BaseFixedWidthVector {
+ public static final byte TYPE_WIDTH = 16;
+ private static final byte DAY_OFFSET = 4;
+ private static final byte NANOSECOND_OFFSET = 8;
+ private final FieldReader reader;
+
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, BufferAllocator allocator) {
+ this(name, FieldType.nullable(MinorType.INTERVALDAY.getType()), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param name name of the vector
+ * @param fieldType type of Field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(String name, FieldType fieldType, BufferAllocator allocator) {
+ this(new Field(name, fieldType, null), allocator);
+ }
+
+ /**
+ * Instantiate a IntervalMonthDayNanoVector. This doesn't allocate any memory for
+ * the data in vector.
+ *
+ * @param field field materialized by this vector
+ * @param allocator allocator for memory management.
+ */
+ public IntervalMonthDayNanoVector(Field field, BufferAllocator allocator) {
+ super(field, allocator, TYPE_WIDTH);
+ reader = new IntervalMonthDayNanoReaderImpl(IntervalMonthDayNanoVector.this);
+ }
+
+ /**
+ * Get a reader that supports reading values from this vector.
+ *
+ * @return Field Reader for this vector
+ */
+ @Override
+ public FieldReader getReader() {
+ return reader;
+ }
+
+ /**
+ * Get minor type for this vector. The vector holds values belonging
+ * to a particular type.
+ *
+ * @return {@link org.apache.arrow.vector.types.Types.MinorType}
+ */
+ @Override
+ public MinorType getMinorType() {
+ return MinorType.INTERVALMONTHDAYNANO;
+ }
+
+
+ /*----------------------------------------------------------------*
+ | |
+ | vector value retrieval methods |
+ | |
+ *----------------------------------------------------------------*/
+
+ /**
+ * Given a data buffer, get the number of months stored at a particular position
+ * in the vector.
+ *
+ * <p>This method should not be used externally.
Review comment:
This unfortunately is a pattern established for integration testing which lives in a separate package.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-831478419
@jorisvandenbossche good point. Added some text, let me know if it makes sense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] alamb commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-828578381
> I actually liked the argument for having the finest grained available data available of other Arrow temporal types. I'm not sure any alignment is going to be perfect.
Makes sense to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] wesm commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
wesm commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r627537881
##########
File path: format/Schema.fbs
##########
@@ -17,6 +17,11 @@
/// Logical types, vector layouts, and schemas
+/// Format Version History.
+/// Version 1.0 - Forward and backwards compatibility guaranteed.
+/// Version 1.1 - Add Decimal256 (No format release).
+/// Version 1.2 (Pending)- Add Interval DAY_TIME_NANO
Review comment:
MONTH_DAY_NANO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-852271089
It was not, sorry, I've been delayed in the implementation which I think is
a prerequisite for a vote.
On Tue, Jun 1, 2021 at 9:23 AM Antoine Pitrou ***@***.***>
wrote:
> Was this voted on already? I forget.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/arrow/pull/10177#issuecomment-852259288>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AEIKYDSIFY66ZYYPSS7RUODTQUCR5ANCNFSM43VPY5AA>
> .
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r691851124
##########
File path: java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.junit.Test;
+
+public class TestPeriodDuration {
+
+ @Test
+ public void testBasics() {
+ PeriodDuration pd1 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(123));
+ PeriodDuration pdEq1 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(123));
+ PeriodDuration pd2 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(12));
+ PeriodDuration pd3 = new PeriodDuration(Period.of(1, 2, 0), Duration.ofNanos(123));
Review comment:
maybe we need some cases for which the month/day/nano are negative?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r621931215
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
Review comment:
Spell out "number" in whole?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690515488
##########
File path: cpp/src/arrow/ipc/json_simple.cc
##########
@@ -410,6 +410,41 @@ class DayTimeIntervalConverter final
std::shared_ptr<DayTimeIntervalBuilder> builder_;
};
+class MonthDayNanoIntervalConverter final
+ : public ConcreteConverter<MonthDayNanoIntervalConverter> {
+ public:
+ explicit MonthDayNanoIntervalConverter(const std::shared_ptr<DataType>& type) {
+ this->type_ = type;
+ builder_ = std::make_shared<MonthDayNanoIntervalBuilder>(default_memory_pool());
+ }
+
+ Status AppendValue(const rj::Value& json_obj) override {
+ if (json_obj.IsNull()) {
+ return this->AppendNull();
+ }
+ MonthDayNanoIntervalType::MonthDayNanos value;
+ if (!json_obj.IsArray()) {
+ return JSONTypeError("array", json_obj.GetType());
+ }
+ if (json_obj.Size() != 3) {
+ return Status::Invalid(
+ "month day nanos interval pair must have exactly two elements, had ",
Review comment:
sorry, fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r691331643
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -998,6 +1004,36 @@ std::shared_ptr<arrow::RecordBatch> GenerateBatch(const FieldVector& fields,
int64_t length, SeedType seed) {
return RandomArrayGenerator(seed).BatchOf(fields, length);
}
-
} // namespace random
+
+void rand_day_millis(int64_t N, std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
Review comment:
Since we're using `pcg32_fast` in RandomArrayGenerator, use it here too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r622724624
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
Review comment:
captured this comment, left day-time ambiguous for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r622293962
##########
File path: format/Schema.fbs
##########
@@ -246,15 +246,21 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
// 4-byte integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANOS - A triple of # of elapsted months, days, and nanoseconds.
Review comment:
NANO seems more consistent with YEAR_MONTH. I'll address the other comments
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-905697256
@pitrou @liyafan82 any more feedback? Otherwise I'd like to get this merged so I can start on the follow-up items from the vote (I'll merge end of week unless there are more comments or we have more concerns about the integration tests)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696006144
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3060,4 +3098,14 @@ TEST(TestSwapEndianArrayData, ExtensionType) {
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}
+TEST(TestSwapEndianArrayData, MonthDayNanoInterval) {
+ auto array = ArrayFromJSON(month_day_nano_interval(), R"([[0, 1, 2],
+ [5000, 200, 3000000000]])");
+ auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(array->data()));
+ EXPECT_TRUE(!swap_array->Equals(array));
+ ASSERT_ARRAYS_EQUAL(
+ *MakeArray(*::arrow::internal::SwapEndianArrayData(swap_array->data())), *array);
+ ASSERT_OK(swap_array->ValidateFull());
+}
Review comment:
actuall, I did . See line 3110
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689592888
##########
File path: cpp/src/arrow/type.h
##########
@@ -1317,6 +1317,40 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType {
std::string name() const override { return "day_time_interval"; }
};
+/// \brief Represents a number of days and milliseconds (fraction of day).
Review comment:
Update docstring? (this looks like a paste of the `DayTimeIntervalType` docstring)
##########
File path: cpp/src/arrow/array/array_primitive.h
##########
@@ -132,4 +136,33 @@ class ARROW_EXPORT DayTimeIntervalArray : public PrimitiveArray {
const uint8_t* raw_values() const { return raw_values_ + data_->offset * byte_width(); }
};
+/// \brief Array of Month, Day and nanosecond values.
+class ARROW_EXPORT MonthDayNanoIntervalArray : public PrimitiveArray {
+ public:
+ using TypeClass = MonthDayNanoIntervalType;
+
+ explicit MonthDayNanoIntervalArray(const std::shared_ptr<ArrayData>& data);
+
+ MonthDayNanoIntervalArray(const std::shared_ptr<DataType>& type, int64_t length,
+ const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ MonthDayNanoIntervalArray(int64_t length, const std::shared_ptr<Buffer>& data,
+ const std::shared_ptr<Buffer>& null_bitmap = NULLPTR,
+ int64_t null_count = kUnknownNullCount, int64_t offset = 0);
+
+ TypeClass::MonthDayNanos GetValue(int64_t i) const;
+ TypeClass::MonthDayNanos Value(int64_t i) const { return GetValue(i); }
+
+ // For compatibility with Take kernel.
+ TypeClass::MonthDayNanos GetView(int64_t i) const { return GetValue(i); }
+
+ int32_t byte_width() const { return sizeof(TypeClass::MonthDayNanos); }
+ static_assert(sizeof(TypeClass::MonthDayNanos) == 16,
+ "MonthDayNanos should only take 16 bytes");
Review comment:
This is already in `type.h`, no need to repeat it here IMHO.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
Hmm... it seems you should view a `fixed_size_binary(16)` instead.
Also, can you add some tests in `random_test.cc`?
##########
File path: cpp/src/arrow/compute/kernels/scalar_set_lookup_test.cc
##########
@@ -803,6 +803,24 @@ TEST_F(TestIndexInKernel, FixedSizeBinary) {
CheckIndexIn(fixed_size_binary(0), R"([])", R"([])", R"([])");
}
+TEST_F(TestIndexInKernel, MonthDayNanoInterval) {
+ auto type = month_day_nano_interval();
+
+ CheckIndexIn(type,
+ /*input=*/R"([[5, -1, 5], null, [4, 5, 6], [5, -1, 5], [1, 2, 3]])",
+ /*value_set=*/R"([null, [4, 5, 6], [5, -1, 5]])",
+ /*expected=*/R"([2, 0, 1, 2, null])",
+ /*skip_nulls=*/false);
+
+ // Duplicates in value_set
+ CheckIndexIn(
+ type,
+ /*input=*/R"([[7, 8, 0], null, [0, 0, 0], [7, 8, 0], [0, 0, 1]])",
+ /*value_set=*/R"([null, null, [0, 0, 0], [0, 0, 0], [7, 8, 0], [7, 8, 0]])",
+ /*expected=*/R"([4, 0, 2, 4, null])",
+ /*skip_nulls=*/false);
+}
+
Review comment:
Interesting! Do you think it's useful to add implementation for other interval types or not?
##########
File path: cpp/src/arrow/type.h
##########
@@ -1317,6 +1317,40 @@ class ARROW_EXPORT DayTimeIntervalType : public IntervalType {
std::string name() const override { return "day_time_interval"; }
};
+/// \brief Represents a number of days and milliseconds (fraction of day).
+class ARROW_EXPORT MonthDayNanoIntervalType : public IntervalType {
+ public:
+ struct MonthDayNanos {
+ int32_t months;
+ int32_t days;
+ int64_t nanoseconds;
+ bool operator==(MonthDayNanos other) const {
+ return this->months == other.months && this->days == other.days &&
+ this->nanoseconds == other.nanoseconds;
+ }
+ bool operator!=(MonthDayNanos other) const { return !(*this == other); }
+ };
+ using c_type = MonthDayNanos;
+ using PhysicalType = MonthDayNanoIntervalType;
+
+ static_assert(sizeof(MonthDayNanos) == 16,
+ "MonthDayNanos struct assumed to be of size 8 bytes");
Review comment:
Fix message?
##########
File path: cpp/src/arrow/testing/random.h
##########
@@ -454,6 +454,37 @@ std::shared_ptr<arrow::Array> GenerateArray(const Field& field, int64_t size,
// Assorted functions
//
+inline void rand_day_millis(int64_t N,
+ std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int32_t> d(std::numeric_limits<int32_t>::min(),
+ std::numeric_limits<int32_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ DayTimeIntervalType::DayMilliseconds tmp;
+ tmp.days = d(gen);
+ tmp.milliseconds = d(gen);
+ return tmp;
+ });
+}
+
+inline void rand_month_day_nanos(
+ int64_t N, std::vector<MonthDayNanoIntervalType::MonthDayNanos>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int64_t> d(std::numeric_limits<int64_t>::min(),
+ std::numeric_limits<int64_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ MonthDayNanoIntervalType::MonthDayNanos tmp;
+ tmp.months = static_cast<int32_t>(d(gen));
+ tmp.days = static_cast<int32_t>(d(gen));
+ tmp.nanoseconds = d(gen);
+ return tmp;
+ });
+}
+
Review comment:
Please don't inline functions which don't need to be inlined. Only put the declarations here.
(also, the pointer-out signature seems unnecessary)
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3060,4 +3098,14 @@ TEST(TestSwapEndianArrayData, ExtensionType) {
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}
+TEST(TestSwapEndianArrayData, MonthDayNanoInterval) {
+ auto array = ArrayFromJSON(month_day_nano_interval(), R"([[0, 1, 2],
+ [5000, 200, 3000000000]])");
+ auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(array->data()));
+ EXPECT_TRUE(!swap_array->Equals(array));
+ ASSERT_ARRAYS_EQUAL(
+ *MakeArray(*::arrow::internal::SwapEndianArrayData(swap_array->data())), *array);
+ ASSERT_OK(swap_array->ValidateFull());
+}
Review comment:
Hmm... it should be pretty easy to check the expected result here.
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -1332,12 +1366,16 @@ TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesLazyIter) {
}
TYPED_TEST(TestPrimitiveBuilder, TestAppendValuesIterConverted) {
- DECL_T();
+ typedef typename TestFixture::CType T;
// find type we can safely convert the tested values to and from
- using conversion_type =
- typename std::conditional<std::is_floating_point<T>::value, double,
- typename std::conditional<std::is_unsigned<T>::value,
- uint64_t, int64_t>::type>::type;
+ using conversion_type = typename std::conditional<
+ std::is_floating_point<T>::value, double,
+ typename std::conditional<
+ std::is_same<T, DayTimeIntervalType::DayMilliseconds>::value ||
+ std::is_same<T, MonthDayNanoIntervalType::MonthDayNanos>::value,
+ T,
+ typename std::conditional<std::is_unsigned<T>::value, uint64_t,
+ int64_t>::type>::type>::type;
Review comment:
Hmm... can you put something on the various P* classes instead?
##########
File path: cpp/src/arrow/testing/random.h
##########
@@ -454,6 +454,37 @@ std::shared_ptr<arrow::Array> GenerateArray(const Field& field, int64_t size,
// Assorted functions
//
+inline void rand_day_millis(int64_t N,
+ std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int32_t> d(std::numeric_limits<int32_t>::min(),
+ std::numeric_limits<int32_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ DayTimeIntervalType::DayMilliseconds tmp;
+ tmp.days = d(gen);
+ tmp.milliseconds = d(gen);
+ return tmp;
+ });
+}
+
+inline void rand_month_day_nanos(
+ int64_t N, std::vector<MonthDayNanoIntervalType::MonthDayNanos>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int64_t> d(std::numeric_limits<int64_t>::min(),
+ std::numeric_limits<int64_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ MonthDayNanoIntervalType::MonthDayNanos tmp;
+ tmp.months = static_cast<int32_t>(d(gen));
+ tmp.days = static_cast<int32_t>(d(gen));
+ tmp.nanoseconds = d(gen);
+ return tmp;
+ });
+}
+
Review comment:
Actually, I'm not even sure where these functions are used?
##########
File path: cpp/src/arrow/ipc/json_simple.cc
##########
@@ -410,6 +410,41 @@ class DayTimeIntervalConverter final
std::shared_ptr<DayTimeIntervalBuilder> builder_;
};
+class MonthDayNanoIntervalConverter final
+ : public ConcreteConverter<MonthDayNanoIntervalConverter> {
+ public:
+ explicit MonthDayNanoIntervalConverter(const std::shared_ptr<DataType>& type) {
+ this->type_ = type;
+ builder_ = std::make_shared<MonthDayNanoIntervalBuilder>(default_memory_pool());
+ }
+
+ Status AppendValue(const rj::Value& json_obj) override {
+ if (json_obj.IsNull()) {
+ return this->AppendNull();
+ }
+ MonthDayNanoIntervalType::MonthDayNanos value;
+ if (!json_obj.IsArray()) {
+ return JSONTypeError("array", json_obj.GetType());
+ }
+ if (json_obj.Size() != 3) {
+ return Status::Invalid(
+ "month day nanos interval pair must have exactly two elements, had ",
Review comment:
Hmm, I think the error message is slightly off.
Also, I think we need to settle on a spelling of the type name. Apparently it's "month_day_nano_interval". Let's not vary gratuitously :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r690647854
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -867,6 +869,7 @@ std::shared_ptr<Array> RandomArrayGenerator::ArrayOf(const Field& field, int64_t
// This isn't as flexible as it could be, but the array-of-structs layout of this
// type means it's not a (useful) composition of other generators
GENERATE_INTEGRAL_CASE_VIEW(Int64Type, DayTimeIntervalType);
+ GENERATE_INTEGRAL_CASE_VIEW(Int64Type, MonthDayNanoIntervalType);
Review comment:
sorry still need to add a test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689931835
##########
File path: cpp/src/arrow/testing/random.h
##########
@@ -454,6 +454,37 @@ std::shared_ptr<arrow::Array> GenerateArray(const Field& field, int64_t size,
// Assorted functions
//
+inline void rand_day_millis(int64_t N,
+ std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int32_t> d(std::numeric_limits<int32_t>::min(),
+ std::numeric_limits<int32_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ DayTimeIntervalType::DayMilliseconds tmp;
+ tmp.days = d(gen);
+ tmp.milliseconds = d(gen);
+ return tmp;
+ });
+}
+
+inline void rand_month_day_nanos(
+ int64_t N, std::vector<MonthDayNanoIntervalType::MonthDayNanos>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
+ std::uniform_int_distribution<int64_t> d(std::numeric_limits<int64_t>::min(),
+ std::numeric_limits<int64_t>::max());
+ out->resize(N, {});
+ std::generate(out->begin(), out->end(), [&d, &gen] {
+ MonthDayNanoIntervalType::MonthDayNanos tmp;
+ tmp.months = static_cast<int32_t>(d(gen));
+ tmp.days = static_cast<int32_t>(d(gen));
+ tmp.nanoseconds = d(gen);
+ return tmp;
+ });
+}
+
Review comment:
they are used in array_test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-897330799
@bkietz curious if you have any thoughts on how I might fix the MSVC error, I'm not sure why the gtest is getting confused.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-900616476
@liyafan82 @pitrou thank you for the reviews, I think I addressed the relevant comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] jorisvandenbossche commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
jorisvandenbossche commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r625320908
##########
File path: format/Schema.fbs
##########
@@ -246,15 +251,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of # of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantitiy of nanoseconds is less represents less
Review comment:
```suggestion
// as days or that the quantitiy of nanoseconds represents less
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-887606521
Yes still planning on it. Hopefully will have some time this week.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-904522392
Are the Rust integration failures expected? the CI builds are green on git master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] alamb commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r688913459
##########
File path: java/format/src/main/java/org/apache/arrow/flatbuf/Timestamp.java
##########
@@ -29,8 +29,33 @@
* leap seconds, as a 64-bit integer. Note that UNIX time does not include
* leap seconds.
*
- * The Timestamp metadata supports both "time zone naive" and "time zone
- * aware" timestamps. Read about the timezone attribute for more detail
+ * Date & time libraries often have multiple different data types for temporal
+ * data. In order to ease interoperability between different implementations the
+ * Arrow project has some recommendations for encoding these types into a Timestamp
+ * column.
+ *
+ * An "instant" represents a single moment in time that has no meaningful time zone
+ * or the time zone is unknown. A column of instants can also contain values from
+ * multiple time zones. To encode an instant set the timezone string to "UTC".
+ *
+ * A "zoned date-time" represents a single moment in time that has a meaningful
+ * reference time zone. To encode a zoned date-time as a Timestamp set the timezone
+ * string to the name of the timezone. There is some ambiguity between an instant
+ * and a zoned date-time with the UTC time zone. Both of these are stored the same.
+ * Typically, this distinction does not matter. If it does, then an application should
Review comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] liyafan82 commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
liyafan82 commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689234920
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/PeriodDuration.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import java.time.Duration;
+import java.time.Period;
+
+/**
+ * Combination of Period and Duration for representing this interval type
+ * as a POJO.
+ */
+public class PeriodDuration {
+ private final Period period;
+ private final Duration duration;
+
+ public PeriodDuration(Period period, Duration duration) {
+ this.period = period;
+ this.duration = duration;
+ }
+
+ public Period getPeriod() {
+ return period;
+ }
+
+ public Duration getDuration() {
+ return duration;
+ }
+
+ @Override
+ public String toString() {
+ return period.toString() + " " + duration.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof PeriodDuration)) {
+ return false;
+ }
+ PeriodDuration other = (PeriodDuration) o;
+ return this.period.equals(other.period) && this.duration.equals(other.duration);
Review comment:
do we allow cases where the `period` or `duration` are null?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-827809478
<!--
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.
-->
Thanks for opening a pull request!
If this is not a [minor PR](https://github.com/apache/arrow/blob/master/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on JIRA? https://issues.apache.org/jira/browse/ARROW
Opening JIRAs ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename pull request title in the following format?
ARROW-${JIRA_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
See also:
* [Other pull requests](https://github.com/apache/arrow/pulls/)
* [Contribution Guidelines - How to contribute patches](https://arrow.apache.org/docs/developers/contributing.html#how-to-contribute-patches)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-887328527
Are you planning to write the C++ and Java implementations @emkornfield ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r691331643
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -998,6 +1004,36 @@ std::shared_ptr<arrow::RecordBatch> GenerateBatch(const FieldVector& fields,
int64_t length, SeedType seed) {
return RandomArrayGenerator(seed).BatchOf(fields, length);
}
-
} // namespace random
+
+void rand_day_millis(int64_t N, std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
Review comment:
Since we're using `pcg32_fast` in RandomArrayGenerator, use it here too?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-908866344
Thanks for the reviews. merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696005707
##########
File path: cpp/src/arrow/array/array_test.cc
##########
@@ -3060,4 +3098,14 @@ TEST(TestSwapEndianArrayData, ExtensionType) {
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}
+TEST(TestSwapEndianArrayData, MonthDayNanoInterval) {
+ auto array = ArrayFromJSON(month_day_nano_interval(), R"([[0, 1, 2],
+ [5000, 200, 3000000000]])");
+ auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(array->data()));
+ EXPECT_TRUE(!swap_array->Equals(array));
+ ASSERT_ARRAYS_EQUAL(
+ *MakeArray(*::arrow::internal::SwapEndianArrayData(swap_array->data())), *array);
+ ASSERT_OK(swap_array->ValidateFull());
+}
Review comment:
Strange, I thought I did this. Sorry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r689589106
##########
File path: format/Schema.fbs
##########
@@ -17,6 +17,11 @@
/// Logical types, vector layouts, and schemas
+/// Format Version History.
+/// Version 1.0 - Forward and backwards compatibility guaranteed.
+/// Version 1.1 - Add Decimal256 (No format release).
+/// Version 1.2 (Pending)- Add Interval MONTH_DAY_NANO
Review comment:
Did we actually formalize the notion of format versions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#issuecomment-899581174
@jorgecarleitao
> Should we also declare the format on the c data interface?
I agree this can be done separately.
@emkornfield
> I don't think we've been very consistent here. In the past I think we only did this when we had specific new features in the format, not necessarily new data type. @pitrou I think added the last set, maybe he can comment on why he did this?
AFAICT we've only done this on an ad-hoc basis when specific problems arised. Most additions were related to fuzzing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r688967619
##########
File path: format/Schema.fbs
##########
@@ -269,15 +274,24 @@ table Timestamp {
timezone: string;
}
-enum IntervalUnit: short { YEAR_MONTH, DAY_TIME}
+enum IntervalUnit: short { YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO}
// A "calendar" interval which models types that don't necessarily
// have a precise duration without the context of a base timestamp (e.g.
// days can differ in length during day light savings time transitions).
+// All integers in the types below are stored in the endianness indicated
+// by the schema.
// YEAR_MONTH - Indicates the number of elapsed whole months, stored as
-// 4-byte integers.
+// 4-byte signed integers.
// DAY_TIME - Indicates the number of elapsed days and milliseconds,
// stored as 2 contiguous 32-bit integers (8-bytes in total). Support
// of this IntervalUnit is not required for full arrow compatibility.
+// MONTH_DAY_NANO - A triple of the number of elapsed months, days, and nanoseconds.
+// The values are stored contiguously in 16 byte blocks. Months and
+// days are encoded as 32 bit integers and nanoseconds is encoded as a
+// 64 bit integer. All integers are signed. Each field is independent
+// (e.g. there is no constraint that nanoseconds have the same sign
+// as days or that the quantity of nanoseconds represents less
+// than a day's worth of time).
Review comment:
I think DAY_TIME was problematic because millisecond granularity should have been configurable. We introduced a duration type to handle most of thse.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] quinnj commented on a change in pull request #10177: [Proposal] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
quinnj commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r624747828
##########
File path: format/Schema.fbs
##########
@@ -17,6 +17,11 @@
/// Logical types, vector layouts, and schemas
+/// Format Version History.
+/// Version 1.0 - Forward and backwards compability guaranteed.
Review comment:
```suggestion
/// Version 1.0 - Forward and backwards compatibility guaranteed.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield closed pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield closed pull request #10177:
URL: https://github.com/apache/arrow/pull/10177
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r691021404
##########
File path: java/vector/src/main/java/org/apache/arrow/vector/PeriodDuration.java
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import java.time.Duration;
+import java.time.Period;
+
+/**
+ * Combination of Period and Duration for representing this interval type
+ * as a POJO.
+ */
+public class PeriodDuration {
+ private final Period period;
+ private final Duration duration;
+
+ public PeriodDuration(Period period, Duration duration) {
+ this.period = period;
+ this.duration = duration;
+ }
+
+ public Period getPeriod() {
+ return period;
+ }
+
+ public Duration getDuration() {
+ return duration;
+ }
+
+ @Override
+ public String toString() {
+ return period.toString() + " " + duration.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof PeriodDuration)) {
+ return false;
+ }
+ PeriodDuration other = (PeriodDuration) o;
+ return this.period.equals(other.period) && this.duration.equals(other.duration);
Review comment:
no .added check not null.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r694477958
##########
File path: java/vector/src/test/java/org/apache/arrow/vector/TestPeriodDuration.java
##########
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.arrow.vector;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.time.Duration;
+import java.time.Period;
+
+import org.junit.Test;
+
+public class TestPeriodDuration {
+
+ @Test
+ public void testBasics() {
+ PeriodDuration pd1 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(123));
+ PeriodDuration pdEq1 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(123));
+ PeriodDuration pd2 = new PeriodDuration(Period.of(1, 2, 3), Duration.ofNanos(12));
+ PeriodDuration pd3 = new PeriodDuration(Period.of(1, 2, 0), Duration.ofNanos(123));
Review comment:
done.
##########
File path: cpp/src/arrow/testing/random.cc
##########
@@ -998,6 +1004,36 @@ std::shared_ptr<arrow::RecordBatch> GenerateBatch(const FieldVector& fields,
int64_t length, SeedType seed) {
return RandomArrayGenerator(seed).BatchOf(fields, length);
}
-
} // namespace random
+
+void rand_day_millis(int64_t N, std::vector<DayTimeIntervalType::DayMilliseconds>* out) {
+ const int random_seed = 0;
+ std::default_random_engine gen(random_seed);
Review comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] emkornfield commented on a change in pull request #10177: ARROW-13628: [Format][C++][Java] Add MONTH_DAY_NANO interval type
Posted by GitBox <gi...@apache.org>.
emkornfield commented on a change in pull request #10177:
URL: https://github.com/apache/arrow/pull/10177#discussion_r696006864
##########
File path: cpp/src/arrow/testing/random_test.cc
##########
@@ -108,8 +108,9 @@ auto values = ::testing::Values(
field("time32ms", time32(TimeUnit::MILLI)), field("time64ns", time64(TimeUnit::NANO)),
field("time32s", time32(TimeUnit::SECOND)),
field("time64us", time64(TimeUnit::MICRO)), field("month_interval", month_interval()),
- field("daytime_interval", day_time_interval()), field("listint8", list(int8())),
- field("listlistint8", list(list(int8()))),
+ field("daytime_interval", day_time_interval()),
Review comment:
@pitrou regarding test for andom, is this not sufficient?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org