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

NEW Macros #15

Merged
merged 7 commits into from
Nov 7, 2024
Merged

NEW Macros #15

merged 7 commits into from
Nov 7, 2024

Conversation

lmangani
Copy link
Collaborator

@lmangani lmangani commented Oct 23, 2024

JSON Macros

  • JSONExtract: Extracts a value based on a specified key and converts it to the given type.
  • JSONExtractRaw: Retrieves a value as a raw JSON string without type conversion.
  • JSONHas: Checks if a specified key exists within a JSON object by verifying if the extracted value is not null.
  • JSONLength: Returns the number of elements in a JSON array.
  • JSONType: Expands a JSON object into a set of key-value pairs.
  • JSONExtractKeys: Retrieves the keys of a JSON object as an array.
  • JSONExtractValues: Extracts values from a JSON object, returning them as text.

Comparison Macros

  • equals: Checks if a is equal to b.
  • notEquals: Checks if a is not equal to b.
  • less: Checks if a is less than b.
  • greater: Checks if a is greater than b.
  • lessOrEquals: Checks if a is less than or equal to b.
  • greaterOrEquals: Checks if a is greater than or equal to b.

Scan Macro

  • ch_scan HTTP client helper extended to support multiple formats
D SELECT * FROM ch_scan("SELECT number * 100 FROM numbers(3)","https://play.clickhouse.com", format := "JSON");
┌───────────────────────┐
│ multiply(number, 100) │
│        varchar        │
├───────────────────────┤
│ 0                     │
│ 100                   │
│ 200                   │
└───────────────────────┘
D SELECT * FROM ch_scan("SELECT number * 100 FROM numbers(3)","https://play.clickhouse.com", format := "Parquet");
┌───────────────────────┐
│ multiply(number, 100) │
│        uint64         │
├───────────────────────┤
│                     0 │
│                   100 │
│                   200 │
└───────────────────────┘

@lmangani lmangani changed the title JSON Macros NEW Macros Oct 23, 2024
```
D SET VARIABLE my_map = MAP {'k1': 10, 'k2': 20};
D SELECT dictGet('my_map', 'k1');
```
@lmangani lmangani marked this pull request as ready for review October 25, 2024 14:50
@lmangani lmangani merged commit 40f740f into main Nov 7, 2024
46 checks passed
@lmangani lmangani deleted the json-macros branch November 7, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant