-
Notifications
You must be signed in to change notification settings - Fork 686
feat(materialize): add new backend for Materialize streaming database #11703
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
Open
jasonhernandez
wants to merge
5
commits into
ibis-project:main
Choose a base branch
from
MaterializeInc:feat/add-Materialize-backend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae7bae7
feat(materialize): add new backend for Materialize streaming database
jasonhernandez 48ce9dc
fix(materialize): remove and refactor try blocks, address feedback
jasonhernandez 4dca804
fix(materialize): improve CI test stability and compatibility
jasonhernandez aa07777
Merge branch 'main' into feat/add-Materialize-backend
jasonhernandez cc58b21
fix(materialize): mark upsert tests as notyet for Materialize
jasonhernandez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| DROP TABLE IF EXISTS diamonds CASCADE; | ||
|
|
||
| CREATE TABLE diamonds ( | ||
| carat FLOAT, | ||
| cut TEXT, | ||
| color TEXT, | ||
| clarity TEXT, | ||
| depth FLOAT, | ||
| "table" FLOAT, | ||
| price BIGINT, | ||
| x FLOAT, | ||
| y FLOAT, | ||
| z FLOAT | ||
| ); | ||
|
|
||
| -- Note: In real usage, data would be loaded via sources or INSERT statements | ||
| -- For CI, we'll need to mount CSV files and use a different loading strategy | ||
|
|
||
| DROP TABLE IF EXISTS astronauts CASCADE; | ||
|
|
||
| CREATE TABLE astronauts ( | ||
| "id" BIGINT, | ||
| "number" BIGINT, | ||
| "nationwide_number" BIGINT, | ||
| "name" VARCHAR, | ||
| "original_name" VARCHAR, | ||
| "sex" VARCHAR, | ||
| "year_of_birth" BIGINT, | ||
| "nationality" VARCHAR, | ||
| "military_civilian" VARCHAR, | ||
| "selection" VARCHAR, | ||
| "year_of_selection" BIGINT, | ||
| "mission_number" BIGINT, | ||
| "total_number_of_missions" BIGINT, | ||
| "occupation" VARCHAR, | ||
| "year_of_mission" BIGINT, | ||
| "mission_title" VARCHAR, | ||
| "ascend_shuttle" VARCHAR, | ||
| "in_orbit" VARCHAR, | ||
| "descend_shuttle" VARCHAR, | ||
| "hours_mission" DOUBLE PRECISION, | ||
| "total_hrs_sum" DOUBLE PRECISION, | ||
| "field21" BIGINT, | ||
| "eva_hrs_mission" DOUBLE PRECISION, | ||
| "total_eva_hrs" DOUBLE PRECISION | ||
| ); | ||
|
|
||
| DROP TABLE IF EXISTS batting CASCADE; | ||
|
|
||
| CREATE TABLE batting ( | ||
| "playerID" TEXT, | ||
| "yearID" BIGINT, | ||
| "stint" BIGINT, | ||
| "teamID" TEXT, | ||
| "lgID" TEXT, | ||
| "G" BIGINT, | ||
| "AB" BIGINT, | ||
| "R" BIGINT, | ||
| "H" BIGINT, | ||
| "X2B" BIGINT, | ||
| "X3B" BIGINT, | ||
| "HR" BIGINT, | ||
| "RBI" BIGINT, | ||
| "SB" BIGINT, | ||
| "CS" BIGINT, | ||
| "BB" BIGINT, | ||
| "SO" BIGINT, | ||
| "IBB" BIGINT, | ||
| "HBP" BIGINT, | ||
| "SH" BIGINT, | ||
| "SF" BIGINT, | ||
| "GIDP" BIGINT | ||
| ); | ||
|
|
||
| DROP TABLE IF EXISTS awards_players CASCADE; | ||
|
|
||
| CREATE TABLE awards_players ( | ||
| "playerID" TEXT, | ||
| "awardID" TEXT, | ||
| "yearID" BIGINT, | ||
| "lgID" TEXT, | ||
| "tie" TEXT, | ||
| "notes" TEXT | ||
| ); | ||
|
|
||
| DROP TABLE IF EXISTS functional_alltypes CASCADE; | ||
|
|
||
| CREATE TABLE functional_alltypes ( | ||
| "id" INTEGER, | ||
| "bool_col" BOOLEAN, | ||
| "tinyint_col" SMALLINT, | ||
| "smallint_col" SMALLINT, | ||
| "int_col" INTEGER, | ||
| "bigint_col" BIGINT, | ||
| "float_col" REAL, | ||
| "double_col" DOUBLE PRECISION, | ||
| "date_string_col" TEXT, | ||
| "string_col" TEXT, | ||
| "timestamp_col" TIMESTAMP WITHOUT TIME ZONE, | ||
| "year" INTEGER, | ||
| "month" INTEGER | ||
| ); | ||
|
|
||
| DROP TABLE IF EXISTS tzone CASCADE; | ||
|
|
||
| CREATE TABLE tzone ( | ||
| "ts" TIMESTAMP WITH TIME ZONE, | ||
| "key" TEXT, | ||
| "value" DOUBLE PRECISION | ||
| ); | ||
|
|
||
| INSERT INTO tzone | ||
| SELECT | ||
| CAST('2017-05-28 11:01:31.000400' AS TIMESTAMP WITH TIME ZONE) + | ||
| (t * INTERVAL '1 day' + t * INTERVAL '1 second') AS "ts", | ||
| CHR(97 + t) AS "key", | ||
| t + t / 10.0 AS "value" | ||
| FROM generate_series(0, 9) AS t; | ||
|
|
||
| DROP TABLE IF EXISTS array_types CASCADE; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS array_types ( | ||
| "x" BIGINT[], | ||
| "y" TEXT[], | ||
| "z" DOUBLE PRECISION[], | ||
| "grouper" TEXT, | ||
| "scalar_column" DOUBLE PRECISION, | ||
| "multi_dim" BIGINT[][] | ||
| ); | ||
|
|
||
| -- Note: Materialize does not currently support multi-dimensional arrays containing NULL sub-arrays, so they are not included. | ||
| -- Fix pending: https://github.com/MaterializeInc/materialize/pull/33786 | ||
|
|
||
| INSERT INTO array_types VALUES | ||
| (ARRAY[1::BIGINT, 2::BIGINT, 3::BIGINT], ARRAY['a', 'b', 'c'], ARRAY[1.0::DOUBLE PRECISION, 2.0::DOUBLE PRECISION, 3.0::DOUBLE PRECISION], 'a', 1.0, NULL), | ||
| (ARRAY[4::BIGINT, 5::BIGINT], ARRAY['d', 'e'], ARRAY[4.0::DOUBLE PRECISION, 5.0::DOUBLE PRECISION], 'a', 2.0, NULL), | ||
| (ARRAY[6::BIGINT, NULL], ARRAY['f', NULL], ARRAY[6.0::DOUBLE PRECISION, NULL::DOUBLE PRECISION], 'a', 3.0, NULL), | ||
| (ARRAY[NULL::BIGINT, 1::BIGINT, NULL::BIGINT], ARRAY[NULL, 'a', NULL], ARRAY[]::DOUBLE PRECISION[], 'b', 4.0, NULL), | ||
| (ARRAY[2::BIGINT, NULL, 3::BIGINT], ARRAY['b', NULL, 'c'], NULL, 'b', 5.0, NULL), | ||
| (ARRAY[4::BIGINT, NULL, NULL, 5::BIGINT], ARRAY['d', NULL, NULL, 'e'], ARRAY[4.0::DOUBLE PRECISION, NULL::DOUBLE PRECISION, NULL::DOUBLE PRECISION, 5.0::DOUBLE PRECISION], 'c', 6.0, NULL); | ||
|
|
||
| DROP TABLE IF EXISTS json_t CASCADE; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS json_t (rowid BIGINT, "js" JSONB); | ||
|
|
||
| INSERT INTO json_t VALUES | ||
| (1, '{"a": [1,2,3,4], "b": 1}'), | ||
| (2, '{"a":null,"b":2}'), | ||
| (3, '{"a":"foo", "c":null}'), | ||
| (4, 'null'), | ||
| (5, '[42,47,55]'), | ||
| (6, '[]'), | ||
| (7, '"a"'), | ||
| (8, '""'), | ||
| (9, '"b"'), | ||
| (10, NULL), | ||
| (11, 'true'), | ||
| (12, 'false'), | ||
| (13, '42'), | ||
| (14, '37.37'); | ||
|
|
||
| DROP TABLE IF EXISTS win CASCADE; | ||
|
|
||
| CREATE TABLE win ("g" TEXT, "x" BIGINT, "y" BIGINT); | ||
|
|
||
| INSERT INTO win VALUES | ||
| ('a', 0, 3), | ||
| ('a', 1, 2), | ||
| ('a', 2, 0), | ||
| ('a', 3, 1), | ||
| ('a', 4, 1); | ||
|
|
||
| DROP TABLE IF EXISTS topk CASCADE; | ||
|
|
||
| CREATE TABLE topk ("x" BIGINT); | ||
|
|
||
| INSERT INTO topk VALUES (1), (1), (NULL); | ||
|
|
||
| DROP TABLE IF EXISTS map CASCADE; | ||
|
|
||
| CREATE TABLE map (idx BIGINT, kv JSONB); | ||
|
|
||
| INSERT INTO map VALUES | ||
| (1, '{"a": 1, "b": 2, "c": 3}'), | ||
| (2, '{"d": 4, "e": 5, "f": 6}'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Materialize | ||
|
|
||
| [https://materialize.com](https://materialize.com) | ||
|
|
||
|     | ||
|
|
||
| ## Install | ||
|
|
||
| Install Ibis and dependencies for the Materialize backend: | ||
|
|
||
| ```{.bash} | ||
| pip install 'ibis-framework[materialize]' | ||
| ``` | ||
|
|
||
| And connect: | ||
|
|
||
| ```{.python} | ||
| import ibis | ||
|
|
||
| con = ibis.materialize.connect() # <1> | ||
| ``` | ||
|
|
||
| 1. Adjust connection parameters as needed. | ||
|
|
||
| ## Connect | ||
|
|
||
| ### `ibis.materialize.connect` | ||
|
|
||
| ```python | ||
| con = ibis.materialize.connect( | ||
| user="materialize", | ||
| password="password", | ||
| host="localhost", | ||
| port=6875, | ||
| database="materialize", | ||
| cluster="quickstart", # Optional: specify default cluster | ||
| ) | ||
| ``` | ||
|
|
||
| ::: {.callout-note} | ||
| `ibis.materialize.connect` is a thin wrapper around | ||
| [`ibis.backends.materialize.Backend.do_connect`](#ibis.backends.materialize.Backend.do_connect). | ||
| ::: | ||
|
|
||
| ### Connection Parameters | ||
|
|
||
| ```{python} | ||
| #| echo: false | ||
| #| output: asis | ||
| from _utils import render_do_connect | ||
|
|
||
| render_do_connect("materialize") | ||
| ``` | ||
|
|
||
| ### `ibis.connect` URL format | ||
|
|
||
| In addition to `ibis.materialize.connect`, you can also connect to Materialize by | ||
| passing a properly-formatted connection URL to `ibis.connect`: | ||
|
|
||
| ```python | ||
| con = ibis.connect(f"materialize://{user}:{password}@{host}:{port}/{database}") | ||
| ``` | ||
|
|
||
| ```{python} | ||
| #| echo: false | ||
| BACKEND = "Materialize" | ||
| ``` | ||
|
|
||
| {{< include ./_templates/api.qmd >}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is our recommended healthcheck endpoint