Skip to content

added "DEFAULT_CLI_FORMAT_OPTIONS" for cli and sqllogic test#14052

Merged
jonahgao merged 3 commits intoapache:mainfrom
jatin510:feat/print-null-as-NULL
Jan 11, 2025
Merged

added "DEFAULT_CLI_FORMAT_OPTIONS" for cli and sqllogic test#14052
jonahgao merged 3 commits intoapache:mainfrom
jatin510:feat/print-null-as-NULL

Conversation

@jatin510
Copy link
Copy Markdown
Contributor

@jatin510 jatin510 commented Jan 9, 2025

Which issue does this PR close?

Closes #13872.

Discussions on PR: #14046

Rationale for this change

The null values are printed blank, now they will be printed as "NULL".
Before:

> select make_array(null);
+------------------+
| make_array(NULL) |
+------------------+
| []               |
+------------------+

> select array_repeat(null,0);
+-----------------------------+
| array_repeat(NULL,Int64(0)) |
+-----------------------------+
| []                          |
+-----------------------------+

> select array_repeat(null,1);
+-----------------------------+
| array_repeat(NULL,Int64(1)) |
+-----------------------------+
| []                          |
+-----------------------------+

Now:

> select make_array(null);
+------------------+
| make_array(NULL) |
+------------------+
| [NULL]           |
+------------------+

> select array_repeat(null,0);
+-----------------------------+
| array_repeat(NULL,Int64(0)) |
+-----------------------------+
| []                          |
+-----------------------------+

> select array_repeat(null,1);
+-----------------------------+
| array_repeat(NULL,Int64(1)) |
+-----------------------------+
| [NULL]                      |
+-----------------------------+

What changes are included in this PR?

A DEFAULT_CLI_FORMAT_OPTIONS is added for proper formatting in cli for the null values

Are these changes tested?

Yes, Updated the slt test files.

Are there any user-facing changes?

Yes
Breaking changes in cli

@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Jan 9, 2025
@jatin510 jatin510 changed the title added "DEFAULT_CLI_FORMAT_OPTIONS" for cli and sqllotic test added "DEFAULT_CLI_FORMAT_OPTIONS" for cli and sqllogic test Jan 9, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 9, 2025
Copy link
Copy Markdown
Member

@jonahgao jonahgao left a comment

Choose a reason for hiding this comment

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

LGTM👍

SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, null]);
----
{POST: 41, HEAD: 33, PATCH: }
{POST: 41, HEAD: 33, PATCH: NULL}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is more human-readable to me.

_ => {
let f = ArrayFormatter::try_new(col.as_ref(), &DEFAULT_FORMAT_OPTIONS);
let f =
ArrayFormatter::try_new(col.as_ref(), &DEFAULT_CLI_FORMAT_OPTIONS);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change makes it consistent with

if !col.is_valid(row) {
// represent any null value with the string "NULL"
Ok(NULL_STR.to_string())
} else {

Copy link
Copy Markdown
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍🏻

@jonahgao
Copy link
Copy Markdown
Member

Thanks @jatin510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate documentation Improvements or additions to documentation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Functionality of array_repeat udf

3 participants