Skip to content

Conversation

@yaooqinn
Copy link
Member

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.g4 for 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.

@yaooqinn
Copy link
Member Author

@cloud-fan @maropu @wangyum, please take a look, thanks very much.

@cloud-fan
Copy link
Contributor

is it supported by pgsql as well?

@SparkQA
Copy link

SparkQA commented Nov 14, 2019

Test build #113779 has finished for PR 26520 at commit aba5da7.

  • This patch fails Spark unit tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

@yaooqinn
Copy link
Member Author

yaooqinn commented Nov 14, 2019

PostgreSQL

postgres=# 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)

@SparkQA
Copy link

SparkQA commented Nov 14, 2019

Test build #113781 has finished for PR 26520 at commit 6d912c5.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 14, 2019

Test build #113790 has finished for PR 26520 at commit de21aa8.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 14, 2019

Test build #113793 has finished for PR 26520 at commit 21bd89f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member

maropu commented Nov 15, 2019

@yaooqinn Can you check the other dbmss, e.g., mysql, oracle, presto, ...?

@yaooqinn
Copy link
Member Author

yaooqinn commented Nov 15, 2019

presto

presto 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]

@yaooqinn
Copy link
Member Author

mysql

only 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'

@yaooqinn
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants