You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/03/30 14:38:35 UTC

[GitHub] [arrow-datafusion] alamb opened a new pull request, #5792: Support `INTERVAL` SQL Type

alamb opened a new pull request, #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792

   # Which issue does this PR close?
   
   Closes https://github.com/apache/arrow-datafusion/issues/5651
   
   # Rationale for this change
   
   See https://github.com/apache/arrow-datafusion/issues/5651 (basically I want to be able to interact with intervals like normal). Also related to https://github.com/apache/arrow-datafusion/pull/5764 from @berkaysynnada
   
   # What changes are included in this PR?
   1. Add basic support for `INTERVAL` SQL --> `DataType::Interval(MonthDayNano)` arrow type
   2. Add code to go to/from ScalarValue and Interval Arrays
   3. Basic tests
   
   # Are these changes tested?
   Yes
   
   # Are there any user-facing changes?
   
   Yes (you can now do `SELECT '1 day'::interval`) and it works!


-- 
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-datafusion] alamb commented on a diff in pull request #5792: Support `INTERVAL` SQL Type

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792#discussion_r1153521186


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -0,0 +1,70 @@
+# 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.
+
+
+# Use `interval` SQL literal syntax
+query TT
+select
+  arrow_typeof(interval '5 months'),
+  arrow_typeof(interval '5 days 3 nanoseconds')
+----
+Interval(YearMonth) Interval(MonthDayNano)
+
+
+# use interval SQL type
+query TT
+select
+  arrow_typeof('5 months'::interval),
+  arrow_typeof('5 days 3 nanoseconds'::interval)
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+# cast with explicit cast sytax
+query TT
+select
+  arrow_typeof(cast ('5 months' as interval)),
+  arrow_typeof(cast ('5 days 3 nanoseconds' as interval))
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+
+# Create tables with interval values
+# (TODO file ticket)

Review Comment:
   Will file a ticket. Thank you for the review



-- 
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-datafusion] alamb merged pull request #5792: Support `INTERVAL` SQL Type

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792


-- 
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-datafusion] alamb commented on a diff in pull request #5792: Support `INTERVAL` SQL Type

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792#discussion_r1153381310


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -0,0 +1,70 @@
+# 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.
+
+
+# Use `interval` SQL literal syntax
+query TT
+select
+  arrow_typeof(interval '5 months'),
+  arrow_typeof(interval '5 days 3 nanoseconds')
+----
+Interval(YearMonth) Interval(MonthDayNano)

Review Comment:
   The fact that this is Interval YearMonth is an artifact -- I think `interval ..` syntax should always be the same type. I will file a ticket to that effect



-- 
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-datafusion] alamb commented on a diff in pull request #5792: Support `INTERVAL` SQL Type

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792#discussion_r1153683090


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -0,0 +1,70 @@
+# 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.
+
+
+# Use `interval` SQL literal syntax
+query TT
+select
+  arrow_typeof(interval '5 months'),
+  arrow_typeof(interval '5 days 3 nanoseconds')
+----
+Interval(YearMonth) Interval(MonthDayNano)
+
+
+# use interval SQL type
+query TT
+select
+  arrow_typeof('5 months'::interval),
+  arrow_typeof('5 days 3 nanoseconds'::interval)
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+# cast with explicit cast sytax
+query TT
+select
+  arrow_typeof(cast ('5 months' as interval)),
+  arrow_typeof(cast ('5 days 3 nanoseconds' as interval))
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+
+# Create tables with interval values
+# (TODO file ticket)

Review Comment:
   https://github.com/apache/arrow-datafusion/issues/5802



-- 
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-datafusion] alamb commented on a diff in pull request #5792: Support `INTERVAL` SQL Type

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792#discussion_r1153682732


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -0,0 +1,70 @@
+# 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.
+
+
+# Use `interval` SQL literal syntax
+query TT
+select
+  arrow_typeof(interval '5 months'),
+  arrow_typeof(interval '5 days 3 nanoseconds')
+----
+Interval(YearMonth) Interval(MonthDayNano)

Review Comment:
   https://github.com/apache/arrow-datafusion/issues/5801



-- 
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-datafusion] tustvold commented on a diff in pull request #5792: Support `INTERVAL` SQL Type

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on code in PR #5792:
URL: https://github.com/apache/arrow-datafusion/pull/5792#discussion_r1153401321


##########
datafusion/core/tests/sqllogictests/test_files/interval.slt:
##########
@@ -0,0 +1,70 @@
+# 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.
+
+
+# Use `interval` SQL literal syntax
+query TT
+select
+  arrow_typeof(interval '5 months'),
+  arrow_typeof(interval '5 days 3 nanoseconds')
+----
+Interval(YearMonth) Interval(MonthDayNano)
+
+
+# use interval SQL type
+query TT
+select
+  arrow_typeof('5 months'::interval),
+  arrow_typeof('5 days 3 nanoseconds'::interval)
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+# cast with explicit cast sytax
+query TT
+select
+  arrow_typeof(cast ('5 months' as interval)),
+  arrow_typeof(cast ('5 days 3 nanoseconds' as interval))
+----
+Interval(MonthDayNano) Interval(MonthDayNano)
+
+
+# Create tables with interval values
+# (TODO file ticket)

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