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

Add Ibis server #545

Merged
merged 2 commits into from
May 10, 2024
Merged

Add Ibis server #545

merged 2 commits into from
May 10, 2024

Conversation

grieve54706
Copy link
Contributor

@grieve54706 grieve54706 commented May 10, 2024

Add a python server for ibis-project/ibis

Query data API

POST /v2/ibis/{data_source}/query

Path parameters

  • data_source: string, required. The name of the data source to query.

    The available values*:*

    • postgres
    • bigquery
    • snowflake

Request body

  • sql: string, required

Other fields determined by data source

For Postgres:

  • host: string, required
  • port: integer, required
  • user: string, required
  • password: string, required
{
  "sql": "select * from orders limit 5",
  "host": "localhost",
  "port": 5432,
  "user": "postgres",
  "password": "postgres"
}

For Bigquery:

  • project_id: string, required
  • dataset_id: string, required
  • credentials: Base64 encode credentials.json
{
  "sql": "select * from tpch_tiny.orders limit 5",
  "project_id": "wrenai",
  "dataset_id": "tpch_tiny",
  "credentials": "ewogICJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsCiAgInByb2plY3Rfa..."
}

For Snowflake:

  • user: string, required
  • password: string, required
  • account: string, required
  • database: string, required
  • schema: string
{
  "sql": "select * from TPCH_SF1.ORDERS LIMIT 5",
  "user": "user",
  "password": "password",
  "account": "snowflake_account",
  "database": "SNOWFLAKE_SAMPLE_DATA"
}

Response body

  • columns
  • data
  • dtypes: Type through the pandas
{
    "columns": [
        "o_orderkey",
        "o_custkey",
        "o_orderstatus",
        "o_totalprice",
        "o_orderdate",
        "o_orderpriority",
        "o_clerk",
        "o_shippriority",
        "o_comment"
    ],
    "data": [
        [
            1,
            370,
            "O",
            172799.49,
            820540800000,
            "5-LOW",
            "Clerk#000000951",
            0,
            "nstructions sleep furiously among "
        ]
    ],
    "dtypes": {
        "o_orderkey": "int32",
        "o_custkey": "int32",
        "o_orderstatus": "object",
        "o_totalprice": "object",
        "o_orderdate": "object",
        "o_orderpriority": "object",
        "o_clerk": "object",
        "o_shippriority": "int32",
        "o_comment": "object"
    }
}

@grieve54706 grieve54706 marked this pull request as ready for review May 10, 2024 10:44
Copy link
Collaborator

@goldmedal goldmedal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. LGTM.

Comment on lines +14 to +15


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just take a note:
I notices that there're different number of empty line between functions or classes. I think we may can find some solution to format the code. To ensure everyone has same coding style.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Intellij IDEA that follows the PEP8. It's a regular coding style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend using ruff. https://github.com/astral-sh/ruff

Nice idea, I will add it in the future.

@goldmedal goldmedal merged commit a7d9130 into main May 10, 2024
3 checks passed
@goldmedal goldmedal deleted the feature/ibis-server branch May 10, 2024 11:09
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.

None yet

3 participants