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

Feat: Support "Typed Array" as a column type #1484

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

MRGRAVITY817
Copy link
Collaborator

@MRGRAVITY817 MRGRAVITY817 commented May 11, 2024

Add typed array as table column type

Resolves #1483 .

Examples

Create table

CREATE TABLE sal_emp (
    name            text,
    pay_by_quarter  integer[],
    schedule        text[][]
);

Inserting value

# Using curly brackets
INSERT INTO sal_emp
    VALUES ('Bill',
    '{10000, 10000, 10000, 10000}',
    '{{"meeting", "lunch"}, {"training", "presentation"}}');

# Using `ARRAY` constructor
INSERT INTO sal_emp
    VALUES ('Carol',
    ARRAY[20000, 25000, 25000, 25000],
    ARRAY[['breakfast', 'consulting'], ['meeting', 'lunch']]);

Accessing value

# Select all
SELECT * FROM sal_emp;

 name  |      pay_by_quarter       |                 schedule
-------+---------------------------+-------------------------------------------
 Bill  | {10000,10000,10000,10000} | {{meeting,lunch},{training,presentation}}
 Carol | {20000,25000,25000,25000} | {{breakfast,consulting},{meeting,lunch}}
(2 rows)

# Select by index
SELECT pay_by_quarter[3] FROM sal_emp;

 pay_by_quarter
----------------
          10000
          25000
(2 rows)

TODOs

  • Add Array variant in DataType enum
  • Create table with array type
  • Insert array value
    • With curly braces { }
    • With ARRAY constructor
  • Access array value

@coveralls
Copy link

coveralls commented May 11, 2024

Pull Request Test Coverage Report for Build 9044941333

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 238 (0.0%) changed or added relevant lines in 10 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.4%) to 97.835%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core/src/data/key.rs 0 1 0.0%
core/src/data/value/json.rs 0 1 0.0%
storages/mongo-storage/src/row/data_type.rs 0 1 0.0%
storages/parquet-storage/src/store_mut.rs 0 1 0.0%
core/src/data/value/convert.rs 0 3 0.0%
core/src/data/value/expr.rs 0 3 0.0%
core/src/data/value/mod.rs 0 5 0.0%
core/src/translate/data_type.rs 0 6 0.0%
storages/mongo-storage/src/row/value.rs 0 98 0.0%
core/src/data/value/array_value.rs 0 119 0.0%
Files with Coverage Reduction New Missed Lines %
core/src/translate/mod.rs 9 95.56%
Totals Coverage Status
Change from base Build 9028068816: -0.4%
Covered Lines: 53693
Relevant Lines: 54881

💛 - Coveralls

@MRGRAVITY817 MRGRAVITY817 changed the title Feat: add (Typed) Array type to DataType enum Feat: Support "Typed Array" as a column type May 11, 2024
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.

Support Typed Array for column type
2 participants