[SPARK-20910][SQL] Add build-in SQL function - UUID#18136
[SPARK-20910][SQL] Add build-in SQL function - UUID#18136wangyum wants to merge 6 commits intoapache:masterfrom wangyum:SPARK-20910
Conversation
|
Test build #77484 has finished for PR 18136 at commit
|
| 46707d92-02f4-4817-8116-a4c3b23e6266 | ||
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Uuid() extends LeafExpression with CodegenFallback { |
There was a problem hiding this comment.
Can you implement codegen for this?
| """) | ||
| // scalastyle:on line.size.limit | ||
| case class Uuid() extends LeafExpression with CodegenFallback { | ||
| override def foldable: Boolean = true |
There was a problem hiding this comment.
I don't think this function is foldable. If this is foldable, it means we might use the same UUID generated by optimizer for all rows.
Conflicts: sql/core/src/test/resources/sql-tests/inputs/string-functions.sql sql/core/src/test/resources/sql-tests/results/string-functions.sql.out
|
Test build #77593 has finished for PR 18136 at commit
|
| override def eval(input: InternalRow): Any = UTF8String.fromString(UUID.randomUUID().toString) | ||
|
|
||
| override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { | ||
| ev.copy(code = s"final ${ctx.javaType(dataType)} ${ev.value} = " + |
There was a problem hiding this comment.
nit: ${ctx.javaType(dataType)} -> UTF8String
| select replace('abc', 'b'); | ||
|
|
||
| -- uuid | ||
| select length(uuid()), (uuid() <> uuid()); |
There was a problem hiding this comment.
This test should work if Uuid is deterministic = false.
There was a problem hiding this comment.
If I don't misunderstand it, I think what @ueshin means is we should set deterministic = false for Uuid expression?
There was a problem hiding this comment.
Ah, yes, thank you for supporting.
|
Test build #77613 has finished for PR 18136 at commit
|
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_() - Returns a universally unique identifier (UUID) string. The value is returned as a canonical UUID 36-character string.", |
|
Test build #77620 has finished for PR 18136 at commit
|
|
LGTM, pending tests. |
|
LGTM |
|
Test build #77626 has finished for PR 18136 at commit
|
|
Thanks! Merging to master. |
|
I just came across this expression and I have a few concerns:
Shall I file a ticket? |
What changes were proposed in this pull request?
Add build-int SQL function - UUID.
How was this patch tested?
unit tests