You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "sanskritimbora (via GitHub)" <gi...@apache.org> on 2025/09/16 21:15:39 UTC
[PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
sanskritimbora opened a new pull request, #852:
URL: https://github.com/apache/arrow-java/pull/852
## What's Changed
Please fill in a description of the changes here.
**This contains breaking changes.** <!-- Remove this line if there are no breaking changes. -->
Closes #NNN.
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2358212286
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
@@ -37,7 +38,34 @@ public TimestampAvaticaParameterConverter(ArrowType.Timestamp type) {}
@Override
public boolean bindParameter(FieldVector vector, TypedValue typedValue, int index) {
- long value = (long) typedValue.toLocal();
+ Object valueObj = typedValue.toLocal();
+ if (valueObj instanceof String) {
+ return bindTimestampAsString(vector, (String) valueObj, index);
+ } else if (valueObj instanceof Long) {
+ return bindTimestampAsLong(vector, (Long) valueObj, index);
+ } else {
+ return false;
+ }
Review Comment:
We do extra checking here to avoid a failed cast - should the other converters do the same?
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
Review Comment:
Hmm, so we only allow timestamps with the `Z` suffix - but we can bind to naive timestamp vectors too. And we don't allow timestamps without the suffix. (We could always relax that later, though.)
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/TimeAvaticaParameterConverterTest.java:
##########
Review Comment:
Why doesn't this test use the same `@BeforeEach` setup as the date tests?
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverterTest.java:
##########
Review Comment:
Ditto here - this should use the same structure as the date tests.
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/DateAvaticaParameterConverterTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.driver.jdbc.converter.impl;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.time.LocalDate;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.DateDayVector;
+import org.apache.arrow.vector.DateMilliVector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.types.DateUnit;
+import org.apache.arrow.vector.types.pojo.ArrowType;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.remote.TypedValue;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class DateAvaticaParameterConverterTest {
+ private RootAllocator allocator;
+
+ @BeforeEach
+ void setUp() {
+ allocator = new RootAllocator(Long.MAX_VALUE);
+ }
+
+ @AfterEach
+ void tearDown() {
+ allocator.close();
+ }
+
+ @Test
+ void testBindParameterWithStringDateMilliVector() {
+ try (DateMilliVector vector = new DateMilliVector("date", allocator)) {
+ DateAvaticaParameterConverter converter =
+ new DateAvaticaParameterConverter(new ArrowType.Date(DateUnit.DAY));
+ String dateStr = "2023-09-15";
+ TypedValue typedValue = TypedValue.create(ColumnMetaData.Rep.STRING.toString(), dateStr);
+ boolean result = converter.bindParameter(vector, typedValue, 0);
+ assertTrue(result);
+ assertEquals((int) LocalDate.parse(dateStr).toEpochDay(), vector.get(0));
Review Comment:
Isn't this wrong? DateMilliVector is supposed to store millisecond timestamps representing dates (yes, this is a bad representation) so it should be `toEpochDay() * 24 * 60 * 60 * 1000`.
--
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
Re: [PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3300602080
Can you create an issue for this, and properly name the PR? ("GH-NNN: Allow binding ISO timestamp strings to date/time types" or something)
--
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
Re: [PR] GH-853 Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3303659686
Thank you for the quick responses and the links, I have linked the PR to the issue created.
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2360717921
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
@@ -37,7 +38,34 @@ public TimestampAvaticaParameterConverter(ArrowType.Timestamp type) {}
@Override
public boolean bindParameter(FieldVector vector, TypedValue typedValue, int index) {
- long value = (long) typedValue.toLocal();
+ Object valueObj = typedValue.toLocal();
+ if (valueObj instanceof String) {
+ return bindTimestampAsString(vector, (String) valueObj, index);
+ } else if (valueObj instanceof Long) {
+ return bindTimestampAsLong(vector, (Long) valueObj, index);
+ } else {
+ return false;
+ }
Review Comment:
Good point, I have updated the other converters to include explicit type checks before casting, just like in the timestamp converter. This ensures safe handling and avoids failed casts.
--
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
Re: [PR] GH-853: Allow ISO String Binding for Date, Time, and Timestamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2383899384
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
Review Comment:
I think we shouldn't allow binding timestamps with timezones to columns that don't have timezones in principle. Although what happens the Z suffix is _probably_ unambiguous in this case I think if we ever allow other timezones then it becomes a problem.
--
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
Re: [PR] GH-853 Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3303649311
Fixes #852
--
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
Re: [PR] GH-853: Allow ISO String Binding for Date, Time, and Timestamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2383903101
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
Review Comment:
@jbonofre or @aiguofer any opinions on the behavior 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
Re: [PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3300646381
(Note that we do NOT use JIRA.)
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3305159298
Can you fix the title?
--
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
Re: [PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3300646126
We use GitHub issues. You should not need approval.
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2360712480
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/DateAvaticaParameterConverterTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.driver.jdbc.converter.impl;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.time.LocalDate;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.DateDayVector;
+import org.apache.arrow.vector.DateMilliVector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.types.DateUnit;
+import org.apache.arrow.vector.types.pojo.ArrowType;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.remote.TypedValue;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class DateAvaticaParameterConverterTest {
+ private RootAllocator allocator;
+
+ @BeforeEach
+ void setUp() {
+ allocator = new RootAllocator(Long.MAX_VALUE);
+ }
+
+ @AfterEach
+ void tearDown() {
+ allocator.close();
+ }
+
+ @Test
+ void testBindParameterWithStringDateMilliVector() {
+ try (DateMilliVector vector = new DateMilliVector("date", allocator)) {
+ DateAvaticaParameterConverter converter =
+ new DateAvaticaParameterConverter(new ArrowType.Date(DateUnit.DAY));
+ String dateStr = "2023-09-15";
+ TypedValue typedValue = TypedValue.create(ColumnMetaData.Rep.STRING.toString(), dateStr);
+ boolean result = converter.bindParameter(vector, typedValue, 0);
+ assertTrue(result);
+ assertEquals((int) LocalDate.parse(dateStr).toEpochDay(), vector.get(0));
Review Comment:
That is correct, I made the correction, thanks for pointing out :)
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2360714527
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/TimeAvaticaParameterConverterTest.java:
##########
Review Comment:
Modified and added. Now it looks uniform.
##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverterTest.java:
##########
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
Re: [PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3300923701
FYI: You can create a new issue from https://github.com/apache/arrow-java/issues/new/choose .
--
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
Re: [PR] Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on PR #852:
URL: https://github.com/apache/arrow-java/pull/852#issuecomment-3300621342
Yes, I have been waiting to receive approval to create a ticket on ASF for Arrow Project. I have sent an email to the dev mail - dev@arrow.apache.org. Once I create the issue I will add more details to the PR.
Is there anything more I can do to expedite this process of receiving access?
--
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
Re: [PR] GH-853: Allow-ISO-String-Binding-for-Date-Time-TimeStamp [arrow-java]
Posted by "sanskritimbora (via GitHub)" <gi...@apache.org>.
sanskritimbora commented on code in PR #852:
URL: https://github.com/apache/arrow-java/pull/852#discussion_r2360720376
##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/converter/impl/TimestampAvaticaParameterConverter.java:
##########
Review Comment:
Yes, that's correct. Currently, we only accept timestamps with the Z suffix, but we can easily relax this restriction later to support naive timestamps if needed.
--
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