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

Experiment to simplify the API #140

Closed
wants to merge 2 commits into from
Closed

Experiment to simplify the API #140

wants to merge 2 commits into from

Conversation

ruslandoga
Copy link
Contributor

@ruslandoga ruslandoga commented Dec 16, 2023

Changes:

  • improve timezone / datetime support

For RowBinary:

clickhouse tz app tz value result
any any %DateTime{time_zone: "Etc/UTC"} dump to unix timestamp
any any %DateTime{time_zone: "Asia/Taipei"} conversion into unix timestamp (this is slow)
UTC UTC %NaiveDateTime{} dump to seconds = unix timestamp (correct)
Europe/Berlin UTC %NaiveDateTime{} dump to seconds = unix timestamp (still correct)
Europe/Berlin Asia/Taipei %NaiveDateTime{} dump to seconds != unix timestamp (incorrect, should raise?)

For queries:

clickhouse tz app tz datetime
  • automatically decode streams
# decode by default (format=RowBinaryWithNamesAndTypes)
DBConnection.run(conn, fn conn ->
  Ch.stream(conn, "select * from numbers limit {limit:UInt64}", %{"limit" => 1_000_000})
  |> Stream.each(&IO.inspect/1)
  |> Stream.run()
end)
# %Ch.Result{rows: [[]], data: <<>>}
# %Ch.Result{rows: [[]], data: <<>>}
# %Ch.Result{rows: [[]], data: <<>>}

# don't decode unknown format
DBConnection.run(conn, fn conn ->
  Ch.stream(conn, "select * from numbers limit {limit:UInt64} format CSV", %{"limit" => 1_000_000})
  |> Stream.each(&IO.inspect/1)
  |> Stream.run()
end)
# %Ch.Result{rows: nil, data: ''}

# don't decode if `decode: false`
DBConnection.run(conn, fn conn ->
  Ch.stream(conn, "select * from numbers limit {limit:UInt64}", %{"limit" => 1_000_000}, decode: false)
  |> Stream.each(&IO.inspect/1)
  |> Stream.run()
end)
# %Ch.Result{rows: nil, data: <<>>}

@ruslandoga ruslandoga changed the title Experiment to simplify the API. Experiment to simplify the API Dec 16, 2023
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.

1 participant