kura 0.4.4 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74c035effdecfe9efbd8aac93065593f8250ad612f110d0aeef99e013209be27
4
- data.tar.gz: 036f84aa09a18fc96668227d2c8379c8e404159e0da95994eaa7386ff5c235b9
3
+ metadata.gz: 6f06565ca49829ddf17062a4b3bc3a060a38e44c19d1d9f30636cec01aef67c3
4
+ data.tar.gz: d5a577529bbd9313f3923f91298fa5897af42c8cc50db8a82af13179a3fb129f
5
5
  SHA512:
6
- metadata.gz: 434f0ed22b2b34c19ca6f296db7130da225ba9a7b141a6d4c6f4e3a80ff5d119bd0271daeafda023daf7fa15eefd32db519ae05cd27e26b82f6babc96f207a42
7
- data.tar.gz: 5fa5947df8551de2399bb8e48228dee99d62d73a8b3a941f6341a8c80944b9cdda9a83ff8fb1f95371271f25287248eaf57660e985e785094ce0ef660857721e
6
+ metadata.gz: '08a14f0ec78b5e6635975cc5a9d39b5e85f9a25eca3041c6edd3e0034331284612bb4c4a869d413edee8f599f7b6b07a70d6958be2e82f493f8e7e2cc08a1136'
7
+ data.tar.gz: e2eb76c7c84f1585bc474b6d7f4f8825b3f6a545de9e110faa5b868818e50ff591b75b80cf47332636d62632d9b9b64d6df01c05559e1fe1e0edb4b33e5cd35b
@@ -1,3 +1,13 @@
1
+ # 0.5.0
2
+
3
+ ## Changes
4
+
5
+ * `Kura::Client#list_tabledata` now return TIMESTAMP value in ISO 8601 format String.
6
+
7
+ ## Enhancements
8
+
9
+ * Accept description field in schema specification at insert&load table.
10
+
1
11
  # 0.4.4
2
12
 
3
13
  ## Enhancements
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
+ require "time"
3
4
  require "json"
4
5
  require "google/apis/bigquery_v2"
5
6
  require "googleauth"
@@ -268,6 +269,8 @@ module Kura
268
269
  end
269
270
  when "BOOLEAN"
270
271
  x.to_s == "true"
272
+ when "TIMESTAMP"
273
+ Time.at(Float(x)).utc.iso8601(6)
271
274
  when "RECORD"
272
275
  _convert_tabledata_row(x, field_info["fields"])
273
276
  else
@@ -409,16 +412,16 @@ module Kura
409
412
  wait: nil,
410
413
  dry_run: false,
411
414
  &blk)
412
- configuration = Google::Apis::BigqueryV2::JobConfiguration.new({
413
- query: Google::Apis::BigqueryV2::JobConfigurationQuery.new({
415
+ configuration = Google::Apis::BigqueryV2::JobConfiguration.new(
416
+ query: Google::Apis::BigqueryV2::JobConfigurationQuery.new(
414
417
  query: sql,
415
418
  allow_large_results: normalize_parameter(allow_large_results),
416
419
  flatten_results: normalize_parameter(flatten_results),
417
420
  priority: priority,
418
421
  use_query_cache: normalize_parameter(use_query_cache),
419
422
  use_legacy_sql: use_legacy_sql,
420
- })
421
- })
423
+ )
424
+ )
422
425
  if mode
423
426
  configuration.query.write_disposition = mode_to_write_disposition(mode)
424
427
  end
@@ -433,15 +436,15 @@ module Kura
433
436
  configuration.query.maximum_bytes_billed = maximum_bytes_billed
434
437
  end
435
438
  if dataset_id and table_id
436
- configuration.query.destination_table = Google::Apis::BigqueryV2::TableReference.new({ project_id: project_id, dataset_id: dataset_id, table_id: table_id })
439
+ configuration.query.destination_table = Google::Apis::BigqueryV2::TableReference.new(project_id: project_id, dataset_id: dataset_id, table_id: table_id)
437
440
  end
438
441
  if user_defined_function_resources
439
442
  configuration.query.user_defined_function_resources = Array(user_defined_function_resources).map do |r|
440
443
  r = r.to_s
441
444
  if r.start_with?("gs://")
442
- Google::Apis::BigqueryV2::UserDefinedFunctionResource.new({ resource_uri: r })
445
+ Google::Apis::BigqueryV2::UserDefinedFunctionResource.new(resource_uri: r)
443
446
  else
444
- Google::Apis::BigqueryV2::UserDefinedFunctionResource.new({ inline_code: r })
447
+ Google::Apis::BigqueryV2::UserDefinedFunctionResource.new(inline_code: r)
445
448
  end
446
449
  end
447
450
  end
@@ -459,6 +462,9 @@ module Kura
459
462
  type: (s[:type] || s["type"]),
460
463
  mode: (s[:mode] || s["mode"]),
461
464
  }
465
+ if (desc = (s[:description] || s["description"]))
466
+ f[:description] = desc
467
+ end
462
468
  if (sub_fields = (s[:fields] || s["fields"]))
463
469
  f[:fields] = normalize_schema(sub_fields)
464
470
  end
@@ -468,6 +474,9 @@ module Kura
468
474
  type: s.type,
469
475
  mode: s.mode,
470
476
  }
477
+ if s.respond_to?(:description)
478
+ f[:description] = s.description
479
+ end
471
480
  if (sub_fields = s.fields)
472
481
  f[:fields] = normalize_schema(sub_fields)
473
482
  end
@@ -493,26 +502,26 @@ module Kura
493
502
  &blk)
494
503
  write_disposition = mode_to_write_disposition(mode)
495
504
  source_uris = [source_uris] if source_uris.is_a?(String)
496
- configuration = Google::Apis::BigqueryV2::JobConfiguration.new({
497
- load: Google::Apis::BigqueryV2::JobConfigurationLoad.new({
498
- destination_table: Google::Apis::BigqueryV2::TableReference.new({
505
+ configuration = Google::Apis::BigqueryV2::JobConfiguration.new(
506
+ load: Google::Apis::BigqueryV2::JobConfigurationLoad.new(
507
+ destination_table: Google::Apis::BigqueryV2::TableReference.new(
499
508
  project_id: project_id,
500
509
  dataset_id: dataset_id,
501
510
  table_id: table_id,
502
- }),
511
+ ),
503
512
  write_disposition: write_disposition,
504
513
  allow_jagged_rows: normalize_parameter(allow_jagged_rows),
505
514
  max_bad_records: max_bad_records,
506
515
  ignore_unknown_values: normalize_parameter(ignore_unknown_values),
507
516
  source_format: source_format,
508
- })
509
- })
517
+ )
518
+ )
510
519
  if dry_run
511
520
  configuration.dry_run = true
512
521
  wait = nil
513
522
  end
514
523
  if schema
515
- configuration.load.schema = Google::Apis::BigqueryV2::TableSchema.new({ fields: normalize_schema(schema) })
524
+ configuration.load.schema = Google::Apis::BigqueryV2::TableSchema.new(fields: normalize_schema(schema))
516
525
  end
517
526
  if source_format == "CSV"
518
527
  configuration.load.field_delimiter = field_delimiter
@@ -541,18 +550,18 @@ module Kura
541
550
  dry_run: false,
542
551
  &blk)
543
552
  dest_uris = [ dest_uris ] if dest_uris.is_a?(String)
544
- configuration = Google::Apis::BigqueryV2::JobConfiguration.new({
545
- extract: Google::Apis::BigqueryV2::JobConfigurationExtract.new({
553
+ configuration = Google::Apis::BigqueryV2::JobConfiguration.new(
554
+ extract: Google::Apis::BigqueryV2::JobConfigurationExtract.new(
546
555
  compression: compression,
547
556
  destination_format: destination_format,
548
- source_table: Google::Apis::BigqueryV2::TableReference.new({
557
+ source_table: Google::Apis::BigqueryV2::TableReference.new(
549
558
  project_id: project_id,
550
559
  dataset_id: dataset_id,
551
560
  table_id: table_id,
552
- }),
561
+ ),
553
562
  destination_uris: dest_uris,
554
- })
555
- })
563
+ )
564
+ )
556
565
  if dry_run
557
566
  configuration.dry_run = true
558
567
  wait = nil
@@ -574,21 +583,21 @@ module Kura
574
583
  dry_run: false,
575
584
  &blk)
576
585
  write_disposition = mode_to_write_disposition(mode)
577
- configuration = Google::Apis::BigqueryV2::JobConfiguration.new({
578
- copy: Google::Apis::BigqueryV2::JobConfigurationTableCopy.new({
579
- destination_table: Google::Apis::BigqueryV2::TableReference.new({
586
+ configuration = Google::Apis::BigqueryV2::JobConfiguration.new(
587
+ copy: Google::Apis::BigqueryV2::JobConfigurationTableCopy.new(
588
+ destination_table: Google::Apis::BigqueryV2::TableReference.new(
580
589
  project_id: dest_project_id,
581
590
  dataset_id: dest_dataset_id,
582
591
  table_id: dest_table_id,
583
- }),
584
- source_table: Google::Apis::BigqueryV2::TableReference.new({
592
+ ),
593
+ source_table: Google::Apis::BigqueryV2::TableReference.new(
585
594
  project_id: src_project_id,
586
595
  dataset_id: src_dataset_id,
587
596
  table_id: src_table_id,
588
- }),
597
+ ),
589
598
  write_disposition: write_disposition,
590
- })
591
- })
599
+ )
600
+ )
592
601
  if dry_run
593
602
  configuration.dry_run = true
594
603
  wait = nil
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chikanaga Tomoyuki
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -139,7 +139,7 @@ homepage: https://github.com/nagachika/kura/
139
139
  licenses:
140
140
  - MIT
141
141
  metadata: {}
142
- post_install_message:
142
+ post_install_message:
143
143
  rdoc_options: []
144
144
  require_paths:
145
145
  - lib
@@ -154,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.1.2
158
- signing_key:
157
+ rubygems_version: 3.1.4
158
+ signing_key:
159
159
  specification_version: 4
160
160
  summary: Interface to BigQuery API v2.
161
161
  test_files: []