-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-29896][SQL] Extend typed literals support for all spark native types #26520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@cloud-fan @maropu @wangyum, please take a look, thanks very much. |
|
is it supported by pgsql as well? |
|
Test build #113779 has finished for PR 26520 at commit
|
PostgreSQLpostgres=# select bool 't';
bool
------
t
(1 row)
postgres=# select float4 '1.00000111';
float4
-----------
1.0000011
(1 row)
postgres=# select float8 '1.00000111';
float8
------------
1.00000111
(1 row)
postgres=# select decimal(10,9) '1.00000111';
numeric
-------------
1.000001110
(1 row)
|
|
Test build #113781 has finished for PR 26520 at commit
|
|
Test build #113790 has finished for PR 26520 at commit
|
|
Test build #113793 has finished for PR 26520 at commit
|
|
@yaooqinn Can you check the other dbmss, e.g., mysql, oracle, presto, ...? |
prestopresto seems all supported presto> select int '1';
_col0
-------
1
(1 row)
Query 20191115_015007_00000_buer4, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:03 [0 rows, 0B] [0 rows/s, 0B/s]
presto> select float '1';
Query 20191115_015020_00001_buer4 failed: line 1:8: Unknown type: float
select float '1'
presto> select float4 '1';
Query 20191115_015026_00002_buer4 failed: line 1:8: Unknown type: float4
select float4 '1'
presto> select bigint '1';
_col0
-------
1
(1 row)
Query 20191115_015057_00003_buer4, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]
presto> select smallint '1';
_col0
-------
1
(1 row)
Query 20191115_015105_00004_buer4, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]
presto> select real '1';
_col0
-------
1.0
(1 row)
Query 20191115_015115_00005_buer4, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]
presto> select bool '1';
Query 20191115_015126_00006_buer4 failed: line 1:8: Unknown type: bool
select bool '1'
presto> select boolean '1';
_col0
-------
true
(1 row)
Query 20191115_015128_00007_buer4, FINISHED, 1 node
Splits: 17 total, 17 done (100.00%)
0:00 [0 rows, 0B] [0 rows/s, 0B/s]
|
mysqlonly date, time types support this, string literals support a character set prefix, numeric and boolean ones does support it. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'smallint '1'' at line 1
mysql> select TINYINT '1';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TINYINT '1'' at line 1
mysql> SELECT timestamp '2019-11-15 00:00:00';
+---------------------------------+
| timestamp '2019-11-15 00:00:00' |
+---------------------------------+
| 2019-11-15 00:00:00 |
+---------------------------------+
1 row in set (0.00 sec)
mysql> SELECT date '2019-11-15';
+-------------------+
| date '2019-11-15' |
+-------------------+
| 2019-11-15 |
+-------------------+
1 row in set (0.00 sec)
mysql> SELECT _utf8'some text';
+-----------+
| some text |
+-----------+
| some text |
+-----------+
1 row in set, 1 warning (0.00 sec)
mysql> SELECT _latin1'string';
+--------+
| string |
+--------+
| string |
+--------+
1 row in set (0.00 sec)
mysql> select boolean 'true';
ERROR 1054 (42S22): Unknown column 'boolean' in 'field list'
mysql> select bool 'true';
ERROR 1054 (42S22): Unknown column 'bool' in 'field list' |
OracleOracle is more akin to mysql |
What changes were proposed in this pull request?
Currently, Date, Timestamp, Interval, Binary, and INTEGER typed literals are supported.
We should support all other native datatypes for this feature.
SQLBase.g4for typeConstructor is changed for decimal support.Why are the changes needed?
improve coverage for typed literals
Does this PR introduce any user-facing change?
yes, add support for native type literals
How was this patch tested?
add ut.