Replies: 2 comments
-
I am not completely sure of what interface that could have, and likely defining a proper interface would be the most complex problem here. One possibility would be to expose a functionality in duckdb-wasm (or directly in duckdb?) that auto-casts column types to varchar, that should give most of the pretty printing sort of for free and with a somewhat clear interface. Example would be going from:
to
This would also allow to sidestep some current problem in the shell rendering for more complex types. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Could be interesting indeed!On Jan 23, 2024, at 04:15, Carlo Piovesan ***@***.***> wrote:
I am not completely sure of what interface that could have, and likely defining a proper interface would be the most complex problem here.
One possibility would be to expose a functionality in duckdb-wasm (or directly in duckdb?) that auto-casts column types to varchar, that should give most of the pretty printing sort of for free and with a somewhat clear interface.
Example would be going from:
SELECT {a:1, b:'hello', c:{c1:'2024-01-01 00:00:00'::TIMESTAMPTZ}} AS col1;
┌─────────────────────────────────────────────────────────────────────┐
│ col1 │
│ struct(a integer, b varchar, c struct(c1 timestamp with time zone)) │
├─────────────────────────────────────────────────────────────────────┤
│ {'a': 1, 'b': hello, 'c': {'c1': 2024-01-01 00:00:00+00}} │
└─────────────────────────────────────────────────────────────────────┘
to
D SELECT COLUMNS(*)::VARCHAR FROM (SELECT {a:1, b:'hello', c:{c1:'2024-01-01 00:00:00'::TIMESTAMPTZ}} AS col1);
RESET
┌───────────────────────────────────────────────────────────┐
│ CAST(unnamed_subquery1.col1 AS VARCHAR) │
│ varchar │
├───────────────────────────────────────────────────────────┤
│ {'a': 1, 'b': hello, 'c': {'c1': 2024-01-01 00:00:00+00}} │
└───────────────────────────────────────────────────────────┘
This would also allow to sidestep some current problem in the shell rendering for more complex types.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Duckdb shell is coded in Rust and it's very nice, but in my case I'd like to let the user do some queries manually, but I want to control the layout and appearance of my results, so I don't want to use the shell "directly".
However, since the queries are user-defined and can be anything, I don't exactly know what will be returned, and I'd like to be able to pretty-print it back to the user, similarly to what is done in the shell
would it be possible to only expose those pretty-printing methods?
Beta Was this translation helpful? Give feedback.
All reactions