@@ -92,7 +92,103 @@ concrete_writer.write(sample_report, 'query')
9292
9393## Configuration
9494
95+ ### arrays
96+
9597Each of writer also support two options for dealing with arrays:
9698
97- * ` WRITER.array-handling ` - arrays handling method: "strings" (default) - store arrays as strings (items combined via a separator, e.g. "item1|item2"), "arrays" - store arrays as arrays.
98- * ` WRITER.array-separator ` - a separator symbol for joining arrays as strings, by default '|'.
99+ * ` WRITER.array_handling ` - arrays handling method:
100+ * ` strings ` (default) - store arrays as strings (items combined via a separator, e.g. "item1|item2")
101+ * ` arrays ` - store arrays as arrays.
102+ * ` WRITER.array_separator ` - a separator symbol for joining arrays as strings, by default '|'.
103+
104+ /// tab | cli
105+ ``` bash
106+ garf query.sql --source API_SOURCE \
107+ --output json \
108+ --json.array-handling=arrays
109+
110+ garf query.sql --source API_SOURCE \
111+ --output json \
112+ --json.array-handling=strings --json.array-separator=' *'
113+ ```
114+ ///
115+
116+ /// tab | python
117+ ``` python
118+ from garf.io.writers import json_writer
119+
120+
121+ array_writer = json_writer.JsonWriter(array_handling = ' arrays' )
122+ string_writer = json_writer.JsonWriter(
123+ array_handling = ' strings' , array_separator = ' *'
124+ )
125+
126+ ```
127+
128+ ### dates
129+
130+ By default ` garf ` writes all date objects as strings. You can overwrite this with two options:
131+
132+ * ` WRITER.date_handling ` - specifies ways of handling date object:
133+ * ` strings ` (default) - keeps date objects as strings .
134+ * ` date ` - formats date objects to proper dates.
135+ * ` datetimes ` - formats date objects to proper datetimes.
136+ * ` timestamps ` - formats date objects to proper timestamps.
137+ * ` WRITER.date_format_string ` - specifies [ format string] ( https://docs.python.org/3/library/datetime.html#format-codes ) .
138+
139+ /// tab | cli
140+ ``` bash
141+ garf query.sql --source API_SOURCE \
142+ --output bq \
143+ --bq.date-handling=dates
144+
145+ garf query.sql --source API_SOURCE \
146+ --output bq \
147+ --bq.date-handling=dates --json.date-format-string=' %d/%m/%y'
148+ ```
149+ ///
150+
151+ /// tab | python
152+ ``` python
153+ from garf.io.writers import bigquery_writer
154+
155+
156+ dates_writer = bigquery_writer.BigQueryWriter(date_handling = ' dates' )
157+ dates_writer_with_format = bigquery_writer.BigQueryWriter(
158+ date_handling = ' dates' ,
159+ date_format_string = ' %d /%m/%y' ,
160+ )
161+ ```
162+
163+ ### prefix / suffix
164+
165+ When writing data with ` garf ` you can use ` prefix ` and ` suffix ` to dynamically
166+ update where (table / file / topic / index) data are written:
167+
168+ /// tab | cli
169+ ``` bash
170+ # Saves results to `my_prefix_query.csv'
171+ garf query.sql --source API_SOURCE \
172+ --output csv \
173+ --csv.prefix=my_prefix
174+
175+ # Saves results to `query_my_suffix.csv'
176+ garf query.sql --source API_SOURCE \
177+ --output csv \
178+ --csv.suffix=my_suffix
179+
180+ # Saves results to `my_prefix_query_my_suffix.csv'
181+ garf query.sql --source API_SOURCE \
182+ --output csv \
183+ --csv.prefix=my_prefix \
184+ --csv.suffix=my_suffix
185+ ```
186+ ///
187+
188+ /// tab | python
189+ ``` python
190+ from garf.io.writers import csv_writer
191+
192+ # Saves results to `my_prefix_query_my_suffix.csv'
193+ writer = csv_writer.CsvWriter(prefix = ' my_prefix' , suffix = ' my_suffix' )
194+ ```
0 commit comments