-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50295: importccl: support DEFAULT columns for constant DEFAULT expressions r=Anzoteh96 a=Anzoteh96 Currently, `IMPORT` does not support importing DEFAULT columns, and non-targeted columns must be nullable. This PR adds support for `IMPORT INTO` that involves non-targeted columns with DEFAULT expressions that are constant. Constant expressions are those that return the same value in different statements. Some examples are: -- Literals (booleans, strings, integers, decimals, dates) -- Functions where each argument is a constant expression and the functions themselves depend solely on their arguments. Examples are arithmetic operations, boolean logical operations (AND, OR), string operations like concat and repeat. In particular, functions like `now()` and `nextval` that return different values across different transactions are not supported. This is done by evaluating the required default expressions in the function `sql/row/row_converter:NewDatumRowConverter`. To illustrate this, given file.csv with content: ``` 35,test 72,hello ``` this will be the expected behaviour of the following line: ``` > CREATE TABLE t (a INT DEFAULT 53, b STRING, c INT DEFAULT 42); > IMPORT INTO t (a, b) CSV DATA ('nodelocal://1/file.csv'); > SELECT * FROM t; a | b | c ----+----- + ------ 35 | test | 42 72 | hello | 42 ``` Note that the default expression for (c) is used since it's non-targeted, but the default expression for (a) is ignored in favour of the column in the csv. Fixes #48253 Release note (general change): `IMPORT INTO` now supports columns with constant default expressions, and non-targeted columns with constant default expressions are no longer required to be nullable. Co-authored-by: anzoteh96 <[email protected]>
- Loading branch information
Showing
3 changed files
with
184 additions
and
29 deletions.
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