Skip to content
Permalink
Browse files

[SPARK-20749][SQL][FOLLOW-UP] Override prettyName for bit_length and …

…octet_length

## What changes were proposed in this pull request?
We need to override the prettyName for bit_length and octet_length for getting the expected auto-generated alias name.

## How was this patch tested?
The existing tests

Author: gatorsmile <gatorsmile@gmail.com>

Closes #20358 from gatorsmile/test2.3More.

(cherry picked from commit ee572ba)
Signed-off-by: hyukjinkwon <gurwls223@gmail.com>
  • Loading branch information...
gatorsmile authored and HyukjinKwon committed Jan 23, 2018
1 parent 832d698 commit 29ed718732de40e956e37f0673743ae375cd30c5
@@ -141,7 +141,7 @@ statement
(LIKE? pattern=STRING)? #showTables
| SHOW TABLE EXTENDED ((FROM | IN) db=identifier)?
LIKE pattern=STRING partitionSpec? #showTable
| SHOW DATABASES (LIKE? pattern=STRING)? #showDatabases
| SHOW DATABASES (LIKE? pattern=STRING)? #showDatabases
| SHOW TBLPROPERTIES table=tableIdentifier
('(' key=tablePropertyKey ')')? #showTblProperties
| SHOW COLUMNS (FROM | IN) tableIdentifier
@@ -1708,6 +1708,8 @@ case class BitLength(child: Expression) extends UnaryExpression with ImplicitCas
case BinaryType => defineCodeGen(ctx, ev, c => s"($c).length * 8")
}
}

override def prettyName: String = "bit_length"
}

/**
@@ -1735,6 +1737,8 @@ case class OctetLength(child: Expression) extends UnaryExpression with ImplicitC
case BinaryType => defineCodeGen(ctx, ev, c => s"($c).length")
}
}

override def prettyName: String = "octet_length"
}

/**
@@ -425,7 +425,7 @@ struct<(7 % 2):int,(7 % 0):int,(0 % 2):int,(7 % CAST(NULL AS INT)):int,(CAST(NUL
-- !query 51
select BIT_LENGTH('abc')
-- !query 51 schema
struct<bitlength(abc):int>
struct<bit_length(abc):int>
-- !query 51 output
24

@@ -449,7 +449,7 @@ struct<length(abc):int>
-- !query 54
select OCTET_LENGTH('abc')
-- !query 54 schema
struct<octetlength(abc):int>
struct<octet_length(abc):int>
-- !query 54 output
3

@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 29
-- Number of queries: 27


-- !query 0
@@ -307,21 +307,22 @@ struct<t1a:string>
val1c
val1d

-- !query 22

-- !query 20
SELECT count(t1a)
FROM t1 RIGHT JOIN t2
ON t1d = t2d
WHERE t1a < (SELECT max(t2a)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 22 schema
-- !query 20 schema
struct<count(t1a):bigint>
-- !query 22 output
-- !query 20 output
7


-- !query 23
-- !query 21
SELECT t1a
FROM t1
WHERE t1b <= (SELECT max(t2b)
@@ -332,14 +333,14 @@ AND t1b >= (SELECT min(t2b)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 23 schema
-- !query 21 schema
struct<t1a:string>
-- !query 23 output
-- !query 21 output
val1b
val1c


-- !query 24
-- !query 22
SELECT t1a
FROM t1
WHERE t1a <= (SELECT max(t2a)
@@ -353,14 +354,14 @@ WHERE t1a >= (SELECT min(t2a)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 24 schema
-- !query 22 schema
struct<t1a:string>
-- !query 24 output
-- !query 22 output
val1b
val1c


-- !query 25
-- !query 23
SELECT t1a
FROM t1
WHERE t1a <= (SELECT max(t2a)
@@ -374,9 +375,9 @@ WHERE t1a >= (SELECT min(t2a)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 25 schema
-- !query 23 schema
struct<t1a:string>
-- !query 25 output
-- !query 23 output
val1a
val1a
val1b
@@ -387,7 +388,7 @@ val1d
val1d


-- !query 26
-- !query 24
SELECT t1a
FROM t1
WHERE t1a <= (SELECT max(t2a)
@@ -401,16 +402,16 @@ WHERE t1a >= (SELECT min(t2a)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 26 schema
-- !query 24 schema
struct<t1a:string>
-- !query 26 output
-- !query 24 output
val1a
val1b
val1c
val1d


-- !query 27
-- !query 25
SELECT t1a
FROM t1
WHERE t1a <= (SELECT max(t2a)
@@ -424,22 +425,22 @@ WHERE t1a >= (SELECT min(t2a)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 27 schema
-- !query 25 schema
struct<t1a:string>
-- !query 27 output
-- !query 25 output
val1a


-- !query 28
-- !query 26
SELECT t1a
FROM t1
GROUP BY t1a, t1c
HAVING max(t1b) <= (SELECT max(t2b)
FROM t2
WHERE t2c = t1c
GROUP BY t2c)
-- !query 28 schema
-- !query 26 schema
struct<t1a:string>
-- !query 28 output
-- !query 26 output
val1b
val1c

0 comments on commit 29ed718

Please sign in to comment.
You can’t perform that action at this time.