keboola.component 1.6.3__tar.gz → 1.6.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. {keboola.component-1.6.3/src/keboola.component.egg-info → keboola.component-1.6.4}/PKG-INFO +54 -1
  2. {keboola.component-1.6.3 → keboola.component-1.6.4}/README.md +53 -0
  3. {keboola.component-1.6.3 → keboola.component-1.6.4}/setup.py +1 -1
  4. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/dao.py +14 -2
  5. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/interface.py +9 -1
  6. {keboola.component-1.6.3 → keboola.component-1.6.4/src/keboola.component.egg-info}/PKG-INFO +54 -1
  7. {keboola.component-1.6.3 → keboola.component-1.6.4}/LICENSE +0 -0
  8. {keboola.component-1.6.3 → keboola.component-1.6.4}/setup.cfg +0 -0
  9. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/__init__.py +0 -0
  10. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/base.py +0 -0
  11. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/exceptions.py +0 -0
  12. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/sync_actions.py +0 -0
  13. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola/component/table_schema.py +0 -0
  14. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola.component.egg-info/SOURCES.txt +0 -0
  15. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola.component.egg-info/dependency_links.txt +0 -0
  16. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola.component.egg-info/not-zip-safe +0 -0
  17. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola.component.egg-info/requires.txt +0 -0
  18. {keboola.component-1.6.3 → keboola.component-1.6.4}/src/keboola.component.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: keboola.component
3
- Version: 1.6.3
3
+ Version: 1.6.4
4
4
  Summary: General library for Python applications running in Keboola Connection environment
5
5
  Home-page: https://github.com/keboola/python-component
6
6
  Author: Keboola KDS Team
@@ -231,6 +231,59 @@ possible to create the container for the output table using the `CommonInterface
231
231
 
232
232
  ![TableDefinition dependencies](docs/imgs/TableDefinition_class.png)
233
233
 
234
+ **Table schema example:**
235
+
236
+ ```python
237
+ from keboola.component import CommonInterface
238
+ from keboola.component.dao import ColumnDefinition, DataType, SupportedDataTypes, BaseType
239
+
240
+ # init the interface
241
+ ci = CommonInterface(data_folder_path='data')
242
+
243
+ # create container for the result
244
+ out = ci.create_out_table_definition("testDef",
245
+ columns=['foo', 'bar'],
246
+ destination='some-destination',
247
+ primary_key=['foo'],
248
+ incremental=True,
249
+ delete_where={'column': 'lilly',
250
+ 'values': ['a', 'b'],
251
+ 'operator': 'eq'})
252
+
253
+ # update column
254
+ out.update_column('foo',
255
+ ColumnDefinition(data_types=BaseType(dtype=SupportedDataTypes.INTEGER, length='20')))
256
+
257
+ # add new columns
258
+ out.add_column('note', ColumnDefinition(nullable=False))
259
+ out.add_column('test1')
260
+ out.add_columns(['test2', 'test3', 'test4'])
261
+
262
+ # add new typed column
263
+ out.add_column('id', ColumnDefinition(primary_key=True,
264
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200')})
265
+ )
266
+
267
+ out.add_columns({
268
+ 'phone': ColumnDefinition(primary_key=True,
269
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200'),
270
+ 'bigquery': DataType(dtype="BIGINT")}),
271
+ 'new2': ColumnDefinition(data_types={'snowflake': DataType(dtype="INTEGER", length='200')}),
272
+ })
273
+
274
+ # delete columns
275
+ out.delete_column('bar')
276
+ out.delete_columns(['test2', 'test3'])
277
+
278
+
279
+ # write some content
280
+ with open(out.full_path, 'w') as result:
281
+ result.write('line')
282
+
283
+ # write manifest
284
+ ci.write_manifest(out)
285
+ ```
286
+
234
287
  **Example:**
235
288
 
236
289
  ```python
@@ -212,6 +212,59 @@ possible to create the container for the output table using the `CommonInterface
212
212
 
213
213
  ![TableDefinition dependencies](docs/imgs/TableDefinition_class.png)
214
214
 
215
+ **Table schema example:**
216
+
217
+ ```python
218
+ from keboola.component import CommonInterface
219
+ from keboola.component.dao import ColumnDefinition, DataType, SupportedDataTypes, BaseType
220
+
221
+ # init the interface
222
+ ci = CommonInterface(data_folder_path='data')
223
+
224
+ # create container for the result
225
+ out = ci.create_out_table_definition("testDef",
226
+ columns=['foo', 'bar'],
227
+ destination='some-destination',
228
+ primary_key=['foo'],
229
+ incremental=True,
230
+ delete_where={'column': 'lilly',
231
+ 'values': ['a', 'b'],
232
+ 'operator': 'eq'})
233
+
234
+ # update column
235
+ out.update_column('foo',
236
+ ColumnDefinition(data_types=BaseType(dtype=SupportedDataTypes.INTEGER, length='20')))
237
+
238
+ # add new columns
239
+ out.add_column('note', ColumnDefinition(nullable=False))
240
+ out.add_column('test1')
241
+ out.add_columns(['test2', 'test3', 'test4'])
242
+
243
+ # add new typed column
244
+ out.add_column('id', ColumnDefinition(primary_key=True,
245
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200')})
246
+ )
247
+
248
+ out.add_columns({
249
+ 'phone': ColumnDefinition(primary_key=True,
250
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200'),
251
+ 'bigquery': DataType(dtype="BIGINT")}),
252
+ 'new2': ColumnDefinition(data_types={'snowflake': DataType(dtype="INTEGER", length='200')}),
253
+ })
254
+
255
+ # delete columns
256
+ out.delete_column('bar')
257
+ out.delete_columns(['test2', 'test3'])
258
+
259
+
260
+ # write some content
261
+ with open(out.full_path, 'w') as result:
262
+ result.write('line')
263
+
264
+ # write manifest
265
+ ci.write_manifest(out)
266
+ ```
267
+
215
268
  **Example:**
216
269
 
217
270
  ```python
@@ -13,7 +13,7 @@ project_urls = {
13
13
 
14
14
  setuptools.setup(
15
15
  name="keboola.component",
16
- version="1.6.3",
16
+ version="1.6.4",
17
17
  author="Keboola KDS Team",
18
18
  project_urls=project_urls,
19
19
  setup_requires=['pytest-runner', 'flake8'],
@@ -582,6 +582,7 @@ class SupportedManifestAttributes(SubscriptableDataclass):
582
582
  elif stage == 'in':
583
583
  attributes = self.in_attributes
584
584
  exclude = self.in_legacy_exclude
585
+
585
586
  else:
586
587
  raise ValueError(f'Unsupported stage {stage}')
587
588
 
@@ -743,6 +744,11 @@ class TableDefinition(IODefinition):
743
744
  "columns",
744
745
  "metadata",
745
746
  "column_metadata",
747
+ "rows_count",
748
+ "data_size_bytes",
749
+ "is_alias",
750
+ "attributes",
751
+ "indexed_columns"
746
752
  ]
747
753
 
748
754
  OUTPUT_MANIFEST_ATTRIBUTES = [
@@ -855,6 +861,8 @@ class TableDefinition(IODefinition):
855
861
  self._rows_count = kwargs.get('rows_count')
856
862
  self._data_size_bytes = kwargs.get('data_size_bytes')
857
863
  self._is_alias = kwargs.get('is_alias')
864
+ self._indexed_columns = kwargs.get('indexed_columns')
865
+ self._attributes = kwargs.get('attributes')
858
866
 
859
867
  self.stage = stage
860
868
  self.has_header = has_header or self._has_header_in_file()
@@ -1107,12 +1115,14 @@ class TableDefinition(IODefinition):
1107
1115
  rows_count=manifest.get('rows_count'),
1108
1116
  data_size_bytes=manifest.get('data_size_bytes'),
1109
1117
  is_alias=manifest.get('is_alias'),
1110
- force_legacy_mode=force_legacy_mode
1118
+ force_legacy_mode=force_legacy_mode,
1119
+ indexed_columns=manifest.get('indexed_columns'),
1120
+ attributes=manifest.get('attributes')
1111
1121
  )
1112
1122
 
1113
1123
  return table_def
1114
1124
 
1115
- def get_manifest_dictionary(self, manifest_type: Optional[str] = 'out', legacy_queue: bool = False,
1125
+ def get_manifest_dictionary(self, manifest_type: Optional[str] = None, legacy_queue: bool = False,
1116
1126
  legacy_manifest: Optional[bool] = None) -> dict:
1117
1127
  """
1118
1128
  Returns manifest dictionary in appropriate manifest_type: either 'in' or 'out'.
@@ -1184,6 +1194,8 @@ class TableDefinition(IODefinition):
1184
1194
  'rows_count': self._rows_count,
1185
1195
  'data_size_bytes': self._data_size_bytes,
1186
1196
  'is_alias': self._is_alias,
1197
+ 'indexed_columns': self._indexed_columns,
1198
+ 'attributes': self._attributes,
1187
1199
 
1188
1200
  'destination': self.destination,
1189
1201
  'incremental': self.incremental,
@@ -950,7 +950,8 @@ class CommonInterface:
950
950
  """
951
951
 
952
952
  if not legacy_manifest:
953
- legacy_manifest = self.environment_variables.data_type_support not in ('authoritative', 'hints')
953
+
954
+ legacy_manifest = self._expects_legacy_manifest()
954
955
 
955
956
  manifest = io_definition.get_manifest_dictionary(legacy_queue=self.is_legacy_queue,
956
957
  legacy_manifest=legacy_manifest)
@@ -959,6 +960,13 @@ class CommonInterface:
959
960
  with open(io_definition.full_path + '.manifest', 'w') as manifest_file:
960
961
  json.dump(manifest, manifest_file)
961
962
 
963
+ def _expects_legacy_manifest(self) -> bool:
964
+ legacy_manifest = self.environment_variables.data_type_support not in ('authoritative', 'hints')
965
+ om_override = self.configuration.config_data.get('storage', {}).get('output', {}).get('data_type_support')
966
+ if om_override:
967
+ legacy_manifest = om_override not in ('authoritative', 'hints')
968
+ return legacy_manifest
969
+
962
970
  def write_manifests(self, io_definitions: List[Union[dao.FileDefinition, dao.TableDefinition]],
963
971
  legacy_manifest: Optional[bool] = None):
964
972
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: keboola.component
3
- Version: 1.6.3
3
+ Version: 1.6.4
4
4
  Summary: General library for Python applications running in Keboola Connection environment
5
5
  Home-page: https://github.com/keboola/python-component
6
6
  Author: Keboola KDS Team
@@ -231,6 +231,59 @@ possible to create the container for the output table using the `CommonInterface
231
231
 
232
232
  ![TableDefinition dependencies](docs/imgs/TableDefinition_class.png)
233
233
 
234
+ **Table schema example:**
235
+
236
+ ```python
237
+ from keboola.component import CommonInterface
238
+ from keboola.component.dao import ColumnDefinition, DataType, SupportedDataTypes, BaseType
239
+
240
+ # init the interface
241
+ ci = CommonInterface(data_folder_path='data')
242
+
243
+ # create container for the result
244
+ out = ci.create_out_table_definition("testDef",
245
+ columns=['foo', 'bar'],
246
+ destination='some-destination',
247
+ primary_key=['foo'],
248
+ incremental=True,
249
+ delete_where={'column': 'lilly',
250
+ 'values': ['a', 'b'],
251
+ 'operator': 'eq'})
252
+
253
+ # update column
254
+ out.update_column('foo',
255
+ ColumnDefinition(data_types=BaseType(dtype=SupportedDataTypes.INTEGER, length='20')))
256
+
257
+ # add new columns
258
+ out.add_column('note', ColumnDefinition(nullable=False))
259
+ out.add_column('test1')
260
+ out.add_columns(['test2', 'test3', 'test4'])
261
+
262
+ # add new typed column
263
+ out.add_column('id', ColumnDefinition(primary_key=True,
264
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200')})
265
+ )
266
+
267
+ out.add_columns({
268
+ 'phone': ColumnDefinition(primary_key=True,
269
+ data_types={'snowflake': DataType(dtype="INTEGER", length='200'),
270
+ 'bigquery': DataType(dtype="BIGINT")}),
271
+ 'new2': ColumnDefinition(data_types={'snowflake': DataType(dtype="INTEGER", length='200')}),
272
+ })
273
+
274
+ # delete columns
275
+ out.delete_column('bar')
276
+ out.delete_columns(['test2', 'test3'])
277
+
278
+
279
+ # write some content
280
+ with open(out.full_path, 'w') as result:
281
+ result.write('line')
282
+
283
+ # write manifest
284
+ ci.write_manifest(out)
285
+ ```
286
+
234
287
  **Example:**
235
288
 
236
289
  ```python