diff --git a/README.md b/README.md index c58af25..9233c85 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Ch.query!(pid, "CREATE TABLE IF NOT EXISTS ch_demo(id UInt64) ENGINE Null") Ch.query!(pid, "INSERT INTO ch_demo(id) SELECT number FROM system.numbers LIMIT {limit:UInt8}", %{"limit" => 2}) ``` -#### Insert rows as [RowBinary](https://clickhouse.com/docs/en/interfaces/formats#rowbinary) (efficient) +#### Insert rows as [RowBinary](https://clickhouse.com/docs/en/interfaces/formats/RowBinary) (efficient) ```elixir {:ok, pid} = Ch.start_link() @@ -106,7 +106,7 @@ types = [:u64] Note that RowBinary format encoding requires `:types` option to be provided. -Similarly, you can use [`RowBinaryWithNamesAndTypes`](https://clickhouse.com/docs/en/interfaces/formats#rowbinarywithnamesandtypes) which would additionally do something like a type check. +Similarly, you can use [RowBinaryWithNamesAndTypes](https://clickhouse.com/docs/en/interfaces/formats/RowBinaryWithNamesAndTypes) which would additionally do something like a type check. ```elixir sql = "INSERT INTO ch_demo FORMAT RowBinaryWithNamesAndTypes" @@ -165,7 +165,7 @@ settings = [async_insert: 1] #### NULL in RowBinary -It's the same as in [`ch-go`](https://clickhouse.com/docs/en/integrations/go#nullable) +It's the same as in [ch-go](https://clickhouse.com/docs/en/integrations/go#nullable) > At insert time, Nil can be passed for both the normal and Nullable version of a column. For the former, the default value for the type will be persisted, e.g., an empty string for string. For the nullable version, a NULL value will be stored in ClickHouse. diff --git a/lib/ch/row_binary.ex b/lib/ch/row_binary.ex index b05f9aa..aa95a03 100644 --- a/lib/ch/row_binary.ex +++ b/lib/ch/row_binary.ex @@ -1,5 +1,5 @@ defmodule Ch.RowBinary do - @moduledoc "Helpers for working with ClickHouse [`RowBinary`](https://clickhouse.com/docs/en/sql-reference/formats#rowbinary) format." + @moduledoc "Helpers for working with ClickHouse [RowBinary](https://clickhouse.com/docs/en/interfaces/formats/RowBinary) format." # @compile {:bin_opt_info, true} @dialyzer :no_improper_lists @@ -28,7 +28,7 @@ defmodule Ch.RowBinary do defp encode_types([] = done), do: done @doc """ - Encodes a single row to [`RowBinary`](https://clickhouse.com/docs/en/sql-reference/formats#rowbinary) as iodata. + Encodes a single row to [RowBinary](https://clickhouse.com/docs/en/interfaces/formats/RowBinary) as iodata. Examples: @@ -50,7 +50,7 @@ defmodule Ch.RowBinary do defp _encode_row([] = done, []), do: done @doc """ - Encodes multiple rows to [`RowBinary`](https://clickhouse.com/docs/en/sql-reference/formats#rowbinary) as iodata. + Encodes multiple rows to [RowBinary](https://clickhouse.com/docs/en/interfaces/formats/RowBinary) as iodata. Examples: @@ -453,7 +453,7 @@ defmodule Ch.RowBinary do defp d(?f), do: 15 @doc """ - Decodes [`RowBinaryWithNamesAndTypes`](https://clickhouse.com/docs/en/sql-reference/formats#rowbinarywithnamesandtypes) into rows. + Decodes [RowBinaryWithNamesAndTypes](https://clickhouse.com/docs/en/interfaces/formats/RowBinaryWithNamesAndTypes) into rows. Example: @@ -474,12 +474,14 @@ defmodule Ch.RowBinary do [["1+1"], [2]] """ + def decode_names_and_rows(row_binary_with_names_and_types) + def decode_names_and_rows(<>) do decode_names(rest, cols, cols, _acc = []) end @doc """ - Decodes [`RowBinary`](https://clickhouse.com/docs/en/sql-reference/formats#rowbinary) into rows. + Decodes [RowBinary](https://clickhouse.com/docs/en/interfaces/formats/RowBinary) into rows. Example: