Skip to content

Support CREATE FUNCTION execution#13561

Merged
rongrong merged 10 commits intoprestodb:masterfrom
caithagoras:s1
Oct 30, 2019
Merged

Support CREATE FUNCTION execution#13561
rongrong merged 10 commits intoprestodb:masterfrom
caithagoras:s1

Conversation

@caithagoras
Copy link
Contributor

@caithagoras caithagoras commented Oct 16, 2019

== RELEASE NOTES ==

General Changes
* Add support for ``CREATE FUNCTION``

@caithagoras
Copy link
Contributor Author

caithagoras commented Oct 24, 2019

@rongrong Thanks for the review! Support MySQL based function namespace manager is the last commit. The commits beyond that have not been finished and will be moved to a separate PR for the purpose of executing CREATE FUNCTION.

Copy link
Contributor

@rongrong rongrong left a comment

Choose a reason for hiding this comment

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

Looks good. Mostly nits.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I mentioned before that getSuffix is more accurate than getUnqualifiedName. If you prefer to use "unqualified name", it's more appropriate to have a utility function unqualifyName(qualifiedName). I'm not sure whether you can call the last part of a qualified name "unqualified name".

Copy link
Contributor Author

@caithagoras caithagoras Oct 29, 2019

Choose a reason for hiding this comment

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

It is a convention to called the last part of a "fully qualified object" (file path, class name, etc) a unqualified name. Here are some reference:

  1. https://stackoverflow.com/a/27966682
  2. https://en.wikipedia.org/wiki/Fully_qualified_name

Because we're defining a specialized class for a fully-qualified function name, it sounds weird to me that it consists of (functionNamespace, suffix)

Copy link
Contributor

Choose a reason for hiding this comment

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

Again, those reference only said a name without prefix is a unqualified name, rather than saying the last part of a qualified name is a "unqualified name". The reference you mentioned also used "suffix", which I still think is better than "unqualified name". If you want to be stubborn on this I won't insist. But I think "suffix" is better than "unqualified name" in this case.

Copy link
Contributor Author

@caithagoras caithagoras Oct 30, 2019

Choose a reason for hiding this comment

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

Looking at some of our existing classes:

  • QualifiedObjectName is defined as (catalogName, schemaName, objectName).
  • QualifiedTablePrefix is defined as (catalogName, schemaName, tableName).

What about defining QualifiedFunctionName as (functionNamespace, functionName)?

Copy link
Contributor

Choose a reason for hiding this comment

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

That should be defined as (CatalogSchemaName functionNamespace, String suffix) then.

Copy link
Contributor

@rongrong rongrong left a comment

Choose a reason for hiding this comment

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

Add some tests to AbstractTestQueries, including explainDdl.

Copy link
Contributor

@rongrong rongrong left a comment

Choose a reason for hiding this comment

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

Please add some tests to AbstractTestQueries and address remaining comments.

@caithagoras
Copy link
Contributor Author

Added explainDdl test.

Use CatalogSchemaName to represent function namespace.

Also
- Fix a bug in getServingFunctionNamespaceManager to correctly
  return the most exact match instead of the least exact match.
- Throw PrestoException when resolving non-builtin functions with
  a QualifiedName with not exactly 3 parts.
Also
- Make SqlInvokedFunction the parameter type for createFunction.
- Store SqlFunctionId within SqlFunctionHandle.
- Convert SqlInvokedFunction#versioned to instance method.
Also rename the class to SqlInvokedFunctionTestUtils
Rollback is not supported by Presto transactions.
@caithagoras
Copy link
Contributor Author

caithagoras commented Oct 30, 2019

  • Added test TestSqlFunctions.
  • Added semantic checks for duplicating column names.
  • Added a TODO to check for SQL invoked functions in function body.
  • Fix an issue when fetching function implementation in FunctionManager.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it simpler to put all names in a set and check the size?

Copy link
Contributor Author

@caithagoras caithagoras Oct 30, 2019

Choose a reason for hiding this comment

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

I need the duplicate parameter names to construct a user-friendly error message, but size checking won't tell me what are duplicated.

Alternatively, printing one name instead of a list is fine with me as well, but I don't think that will make the code simpler.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd just print the whole parameter list lol but sure.

@rongrong
Copy link
Contributor

Thanks for working on this! Looking forward to see this in production!

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.

4 participants