Skip to content
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

Introduce ELT/FIELD methods using VARIADIC and update DESCRIBE FUNCTION #2627

Merged
merged 2 commits into from Apr 4, 2019

Conversation

@agavra
Copy link
Contributor

commented Apr 2, 2019

Description

Proof of concept for variadic functions. This PR introduces the following changes:

  • Introduce ELT, which is based on specification in SQL (see mysql#elt)
  • Introduce FIELD, which is based on specification in SQL (see mysql#field)
  • Introduce variadic syntax to DESCRIBE FUNCTION, which will append [] to any such argument (in line with other SQL systems).
  • Replace references of "vararg" with "variadic" to stay inline with other SQL systems

Testing done

  • New Unit tests
  • QTT tests
  • Ran it using new/old servers and new/old CLIs
ksql> DESCRIBE FUNCTION ELT;

Name        : ELT
Overview    : ELT() returns the Nth element of the list of strings. Returns NULL if N is less than 1 or
               greater than the number of arguments. Note that this method is 1-indexed. This is the
              complement to FIELD.
Type        : scalar
Jar         : internal
Variations  :

	Variation   : ELT(n INTEGER, args VARCHAR[])
	Returns     : VARCHAR
	n           : the nth element to extract
	args        : the strings of which to extract the nth
ksql> DESCRIBE FUNCTION FIELD;

Name        : FIELD
Overview    : Returns the position (1-indexed) of str in args, or 0 if not found. If str is NULL, the
              return value is 0 because NULL is not considered equal to any value. This is the
              compliment to ELT.
Type        : scalar
Jar         : internal
Variations  :

	Variation   : FIELD(str VARCHAR, args VARCHAR[])
	Returns     : INT

TODOs

  • Still can't convert CONCAT to variadic because we don't do automatic casting, so that would be backwards incompatible.

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@agavra agavra requested review from JimGalasyn and confluentinc/ksql as code owners Apr 2, 2019

@agavra agavra added this to the 5.3 milestone Apr 3, 2019

@JimGalasyn
Copy link
Member

left a comment

LGTM

@rodesai

rodesai approved these changes Apr 4, 2019

Copy link
Contributor

left a comment

LGTM

@agavra agavra merged commit 4448cb5 into confluentinc:master Apr 4, 2019

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details

@agavra agavra deleted the agavra:field_elt branch Apr 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.