dssysolyatin commented on code in PR #4002: URL: https://github.com/apache/calcite/pull/4002#discussion_r1861173473
########## babel/src/test/resources/sql/mysql.iq: ########## @@ -0,0 +1,39 @@ +# mysql.iq - Babel test for MySQL dialect of SQL +# +# 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 scott-mysql +!set outputformat mysql + +SELECT cast(cast(TIMESTAMP'1000-01-01 00:00:00' as DATETIME) as DATETIME); ++---------------------+ +| EXPR$0 | ++---------------------+ +| 1000-01-01 00:00:00 | ++---------------------+ +(1 row) + +!ok + +SELECT cast(cast(TIMESTAMP'9999-12-31 23:59:59' as DATETIME) as DATETIME); Review Comment: MySQL syntax is kind of messy 1. Time literals can only be defined using DATE 'str', TIME 'str', or TIMESTAMP 'str'. There is no syntax like DATETIME 'str'. 2. > The [TIMESTAMP](https://dev.mysql.com/doc/refman/8.4/en/datetime.html) syntax produces a [DATETIME](https://dev.mysql.com/doc/refman/8.4/en/datetime.html) value in MySQL because [DATETIME](https://dev.mysql.com/doc/refman/8.4/en/datetime.html) has a range that more closely corresponds to the standard SQL [TIMESTAMP](https://dev.mysql.com/doc/refman/8.4/en/datetime.html) type, which has a year range from 0001 to 9999. (The MySQL [TIMESTAMP](https://dev.mysql.com/doc/refman/8.4/en/datetime.html) year range is 1970 to 2038.) Currently, `SELECT DATETIME '1000-01-01 00:00:00'` works in Calcite when using the MySQL dialect. Ideally, it should throw an exception. However, I’m not sure if anyone actually needs this behavior or if it’s worth spending time on. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
