Skip to content

Conversation

@KKould
Copy link
Member

@KKould KKould commented Mar 24, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

close #17627

-- Create a simple table with JSON data
CREATE TABLE users (user_data VARIANT);

-- Insert two records: one with a null phone number, one with a value
INSERT INTO users 
  SELECT PARSE_JSON('{"name": "Alice", "phone": null}');
  
INSERT INTO users 
  SELECT PARSE_JSON('{"name": "Bob", "phone": "555-1234"}');

-- Compare regular access vs using STRIP_NULL_VALUE
SELECT 
  user_data:name AS name,
  user_data:phone AS original_phone,      -- JSON null appears as 'null'
  STRIP_NULL_VALUE(user_data:phone) AS phone_number  -- Converts JSON null to SQL NULL
FROM users;

-- Result:
-- +----------+----------------+--------------+
-- | NAME     | ORIGINAL_PHONE | PHONE_NUMBER |
-- +----------+----------------+--------------+
-- | "Alice"  | null           | NULL         |
-- | "Bob"    | "555-1234"     | "555-1234"   |
-- +----------+----------------+--------------+

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Mar 24, 2025
@b41sh b41sh self-requested a review March 24, 2025 06:34
@KKould KKould force-pushed the feat/function_strip_null_value branch from b761f85 to 20d4d8b Compare March 24, 2025 08:12
@KKould KKould force-pushed the feat/function_strip_null_value branch from 20d4d8b to f9ed478 Compare March 24, 2025 08:38
@sundy-li sundy-li merged commit 43ab83f into databendlabs:main Mar 24, 2025
77 checks passed
loloxwg pushed a commit to loloxwg/databend that referenced this pull request Apr 3, 2025
* feat: impl function `strip_null_value` for Variant

Signed-off-by: Kould <[email protected]>

* test: add unit test for `strip_null_value` on variant.rs

Signed-off-by: Kould <[email protected]>

---------

Signed-off-by: Kould <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: strip_null_value func

3 participants