Skip to content

[SPARK-26245][SQL] Add Float literal#23199

Closed
wangyum wants to merge 1 commit intoapache:masterfrom
wangyum:SPARK-26245
Closed

[SPARK-26245][SQL] Add Float literal#23199
wangyum wants to merge 1 commit intoapache:masterfrom
wangyum:SPARK-26245

Conversation

@wangyum
Copy link
Member

@wangyum wangyum commented Dec 2, 2018

What changes were proposed in this pull request?

This PR adds parser support for Float literals.

Hive support this feature:
image

How was this patch tested?

unit tests

@SparkQA
Copy link

SparkQA commented Dec 2, 2018

Test build #99568 has finished for PR 23199 at commit 57faa41.

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

@wangyum
Copy link
Member Author

wangyum commented Dec 2, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Dec 2, 2018

Test build #99570 has finished for PR 23199 at commit 57faa41.

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

@wangyum
Copy link
Member Author

wangyum commented Dec 2, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Dec 2, 2018

Test build #99574 has finished for PR 23199 at commit 57faa41.

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

@kiszk
Copy link
Member

kiszk commented Dec 2, 2018

retest this please

@kiszk
Copy link
Member

kiszk commented Dec 2, 2018

cc @maropu @gatorsmile


-- float
select 0F, 1F, 1.2F, -1F, -1.2F, 3.4028235E30F;
select 3.4028235E39F;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move the test cases to the end of the file?

Also clearly specify the positive and negative test cases in the comments?

More test cases are needed.


FLOAT_LITERAL
: DIGIT+ EXPONENT? 'F'
| DECIMAL_DIGITS EXPONENT? 'F' {isValidDecimal()}?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check who supports these Float literals? What are their restrictions?

The ANSI SQL standard does not have such a literal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implementation-specific;

hive> create temporary table t1 as select 1.0F;
hive> describe t1;
OK
f                   	decimal(1,0)  

hive> create temporary table t2 as select 1.0D;
hive> describe t2;
OK
_c0                 	double  
postgres=# create temporary table t1 as select 1.0F;
postgres=# \d t1
 f      | numeric | 

postgres=# create temporary table t2 as select 1.0D;
postgres=# \d t2
 d      | numeric | 

mysql> create temporary table t1 as select 1.0F;
mysql> describe t1;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| F     | decimal(2,1) | NO   |     | 0.0     | NULL  |
+-------+--------------+------+-----+---------+-------+

mysql> create temporary table t2 as select 1.0D;
mysql> describe t2;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| D     | decimal(2,1) | NO   |     | 0.0     | NULL  |
+-------+--------------+------+-----+---------+-------+

@SparkQA
Copy link

SparkQA commented Dec 2, 2018

Test build #99578 has finished for PR 23199 at commit 57faa41.

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

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @wangyum .
In Hive 2.3, 1.0D is considered as Double, but 1.0F is considered as 1.0 F where F is an alias.
In Hive 1.2, 1.0D and 1.0F are considered as 1.0 D and 1.0 F where D and F are aliases.
So, this is not for Hive compatibility. We had better close this PR.

@wangyum wangyum closed this Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants