Conversation
WalkthroughAdds multiple connectors (Redshift, Postgres, MSSQL, Canner), changes query return type to PyArrow tables, introduces unified error handling, implements close semantics, enhances DuckDB behaviors, and adds utilities for UUID/Decimal post-processing and PostgreSQL type-name retrieval in ibis-server/app/model/connector.py. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant Connector as SimpleConnector
participant Ibis as Ibis Backend
participant Arrow as PyArrow
Note over Connector,Ibis: Query execution with PyArrow result
Client->>Connector: query(sql, limit)
Connector->>Ibis: compile/execute(sql, limit)
Ibis-->>Connector: result (backend table)
rect rgb(245,245,255)
Note right of Connector: Post-process unsupported types
Connector->>Connector: _handle_pyarrow_unsupported_type()
Connector->>Connector: _cast_uuid_columns()
Connector->>Connector: _round_decimal_columns(scale=9)
end
Connector->>Arrow: to_arrow()
Arrow-->>Connector: pa.Table
Connector-->>Client: pa.Table
sequenceDiagram
autonumber
actor Client
participant Conn as AnyConnector
participant Backend as Driver/DB
participant Err as WrenError
Note over Conn,Backend: Unified error handling for query/dry_run
Client->>Conn: dry_run(sql) / query(sql)
Conn->>Backend: execute / explain
alt Success
Backend-->>Conn: OK / result
Conn-->>Client: Response
else Backend raises (Trino/ClickHouse/psycopg/...)
Backend-->>Conn: Exception
rect rgb(255,245,245)
Note right of Conn: Map to ErrorCode + ErrorPhase
Conn->>Err: wrap(exception)
end
Err-->>Client: WrenError
end
sequenceDiagram
autonumber
actor Client
participant RS as RedshiftConnector
participant Psy as psycopg Cursor
participant Arrow as PyArrow
Note over RS,Psy: Redshift autocommit + Python-level cursor
Client->>RS: query(sql, limit)
RS->>Psy: execute(sql)
Psy-->>RS: rows / cursor data
RS->>Arrow: to_arrow()
Arrow-->>RS: pa.Table
RS-->>Client: pa.Table
Client->>RS: close()
RS-->>Client: closed
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ibis-server/app/model/connector.py(7 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ibis-server/app/model/connector.py (6)
ibis-server/tests/routers/v2/connector/test_postgres.py (1)
postgres(136-149)ibis-server/app/model/__init__.py (3)
GcsFileConnectionInfo(318-338)MinioFileConnectionInfo(292-315)S3FileConnectionInfo(271-289)ibis-server/app/model/data_source.py (3)
DataSource(42-67)get_connection(57-61)get_connection(88-98)ibis-server/app/routers/v2/connector.py (1)
query(45-151)ibis-server/app/routers/v3/connector.py (1)
query(41-153)ibis-server/tests/routers/v2/connector/test_mssql.py (1)
mssql(80-107)
| ibis_table = self.connection.sql(sql) | ||
| if limit is not None: | ||
| ibis_table = ibis_table.limit(limit) | ||
| return self._round_decimal_columns(ibis_table) |
There was a problem hiding this comment.
Unicode prefix never reaches MSSQL execution.
fixed_sql is computed with _add_unicode_prefix, but the subsequent self.connection.sql(sql) call still runs the original SQL, so the N-prefix fix is lost and Unicode literals stay broken. Apply the fix to use the rewritten SQL.
- ibis_table = self.connection.sql(sql)
+ ibis_table = self.connection.sql(fixed_sql)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ibis_table = self.connection.sql(sql) | |
| if limit is not None: | |
| ibis_table = ibis_table.limit(limit) | |
| return self._round_decimal_columns(ibis_table) | |
| ibis_table = self.connection.sql(fixed_sql) | |
| if limit is not None: | |
| ibis_table = ibis_table.limit(limit) | |
| return self._round_decimal_columns(ibis_table) |
🤖 Prompt for AI Agents
In ibis-server/app/model/connector.py around lines 321 to 324, the method
computes a rewritten SQL (fixed_sql) with _add_unicode_prefix but then calls
self.connection.sql(sql) so the N-prefix never reaches MSSQL; change the call to
use the rewritten SQL (e.g., self.connection.sql(fixed_sql)), ensuring fixed_sql
is created (call _add_unicode_prefix(sql) if not already) before applying limit
and returning the rounded table.
|
@ansutung, could you rebase on the latest main and add the description for what you want to propose? |
|
It may be a duplicate of #1338 |
Summary by CodeRabbit
New Features
Bug Fixes