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

added "DEFAULT_CLI_FORMAT_OPTIONS" for cli and sqllogic test #14052

Merged
merged 3 commits into from
Jan 11, 2025

Conversation

jatin510
Copy link
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
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👍

@@ -195,7 +195,7 @@ SELECT MAP('type', 'test');

SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, null]);
----
{POST: 41, HEAD: 33, PATCH: }
{POST: 41, HEAD: 33, PATCH: NULL}
Copy link
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.

@@ -240,7 +240,8 @@ pub fn cell_to_string(col: &ArrayRef, row: usize) -> Result<String> {
Ok(cell_to_string(dict.values(), key)?)
}
_ => {
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
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
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 jonahgao merged commit 17446ad into apache:main Jan 11, 2025
26 checks passed
@jonahgao
Copy link
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