forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds basic support for building UDFs in optbuilder. Only scalar, nullary (arity of zero) functions with a single statement in the body are supported. Support for more types of UDFs will follow in future commits. Note that this commit does not add support for execution of UDFs, only building them within an optimizer expression. Release note: None
- Loading branch information
Showing
6 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
exec-ddl | ||
CREATE FUNCTION one() RETURNS INT LANGUAGE SQL AS 'SELECT 1'; | ||
---- | ||
|
||
# Do not attempt to hoist UDFs. | ||
norm | ||
SELECT one() | ||
---- | ||
values | ||
├── columns: one:2 | ||
├── cardinality: [1 - 1] | ||
├── key: () | ||
├── fd: ()-->(2) | ||
└── tuple | ||
└── user-defined-function: one | ||
└── values | ||
├── columns: "?column?":1!null | ||
├── cardinality: [1 - 1] | ||
├── key: () | ||
├── fd: ()-->(1) | ||
└── (1,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,68 @@ | ||
exec-ddl | ||
CREATE TABLE abc ( | ||
a INT PRIMARY KEY, | ||
b INT, | ||
c INT | ||
) | ||
---- | ||
|
||
build | ||
SELECT foo() | ||
---- | ||
error (42883): unknown function: foo() | ||
error (42883): unknown function: foo | ||
|
||
exec-ddl | ||
CREATE FUNCTION one() RETURNS INT LANGUAGE SQL AS 'SELECT 1'; | ||
---- | ||
|
||
build | ||
SELECT one() | ||
---- | ||
project | ||
├── columns: one:2 | ||
├── values | ||
│ └── () | ||
└── projections | ||
└── user-defined-function: one [as=one:2] | ||
└── project | ||
├── columns: "?column?":1!null | ||
├── values | ||
│ └── () | ||
└── projections | ||
└── 1 [as="?column?":1] | ||
|
||
build | ||
SELECT *, one() FROM abc | ||
---- | ||
project | ||
├── columns: a:1!null b:2 c:3 one:7 | ||
├── scan abc | ||
│ └── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 | ||
└── projections | ||
└── user-defined-function: one [as=one:7] | ||
└── project | ||
├── columns: "?column?":6!null | ||
├── values | ||
│ └── () | ||
└── projections | ||
└── 1 [as="?column?":6] | ||
|
||
build | ||
SELECT * FROM abc WHERE one() = c | ||
---- | ||
project | ||
├── columns: a:1!null b:2 c:3 | ||
└── select | ||
├── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 | ||
├── scan abc | ||
│ └── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 | ||
└── filters | ||
└── eq | ||
├── user-defined-function: one | ||
│ └── project | ||
│ ├── columns: "?column?":6!null | ||
│ ├── values | ||
│ │ └── () | ||
│ └── projections | ||
│ └── 1 [as="?column?":6] | ||
└── c:3 |