presto-client 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/ChangeLog +5 -0
- data/Rakefile +1 -1
- data/lib/presto/client/models.rb +141 -54
- data/lib/presto/client/version.rb +1 -1
- data/modelgen/modelgen.rb +6 -7
- data/modelgen/models.rb +13 -1
- metadata +3 -3
- data/presto-client.rb +0 -420
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjgzOWE1ZjExOWQzMWUxZmFiZTgwODcyYzMyZTMyNzcyZDkyYWI4Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmU2YzJlZDBmN2ZmYzAxNzJhMmY4N2I1NGMyNGE5N2U4MzQzYzkxYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2U2ZTNkOWVjZmEyZWZjOGVhMTA4M2FhYWU2YTBkZGY1ZDE5Yjg0YTU4Njc3
|
10
|
+
ZWMzOWU2NjQzODViYjhiOGFkZGY0MmY4YjI1ZTk4MmY3ZmE5NmM1ZDQyZjAz
|
11
|
+
MjY1Mjc2MGVlN2M2ZDE5OWI2YzIxNzQwMGU3OTE0MGQ2M2FhY2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTAzNjk1ZDEyNDc0NTljZjNkMWM0ZGJkYzk1N2JmOTRmZDcwZGQ5MTQ2YWQw
|
14
|
+
MjQ5NDA3MTc0MDZjNjJkMGIxNWNmYWU5ZGFiYTY0NTk4MzkxNTEyMWRmYTdh
|
15
|
+
OTAxYzJiNTNiNDFkYjQ5MGUxNGVkMDY1ZmRiZjQ4M2RiN2QyMzA=
|
data/ChangeLog
CHANGED
data/Rakefile
CHANGED
data/lib/presto/client/models.rb
CHANGED
@@ -102,7 +102,7 @@ module Presto::Client
|
|
102
102
|
when "sample" then SampleNode
|
103
103
|
when "sort" then SortNode
|
104
104
|
when "exchange" then ExchangeNode
|
105
|
-
when "
|
105
|
+
when "remoteSource" then RemoteSourceNode
|
106
106
|
when "join" then JoinNode
|
107
107
|
when "INNER" then JoinNode
|
108
108
|
when "LEFT" then JoinNode
|
@@ -155,12 +155,24 @@ module Presto::Client
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
+
class << WriterTarget =
|
159
|
+
Base.new(:type, :handle)
|
160
|
+
def decode(hash)
|
161
|
+
obj = allocate
|
162
|
+
obj.send(:initialize_struct,
|
163
|
+
hash["type"],
|
164
|
+
hash["type"] == 'InsertHandle' ? InsertTableHandle.decode(hash['handle']) : OutputTableHandle.decode(hash['handle'])
|
165
|
+
)
|
166
|
+
obj
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
158
170
|
##
|
159
171
|
# Those model classes are automatically generated
|
160
172
|
#
|
161
173
|
|
162
174
|
class << AggregationNode =
|
163
|
-
Base.new(:id, :source, :group_by, :aggregations, :functions, :masks, :step, :sample_weight, :confidence)
|
175
|
+
Base.new(:id, :source, :group_by, :aggregations, :functions, :masks, :step, :sample_weight, :confidence, :hash_symbol)
|
164
176
|
def decode(hash)
|
165
177
|
obj = allocate
|
166
178
|
obj.send(:initialize_struct,
|
@@ -173,6 +185,7 @@ module Presto::Client
|
|
173
185
|
hash["step"] && hash["step"].downcase.to_sym,
|
174
186
|
hash["sampleWeight"],
|
175
187
|
hash["confidence"],
|
188
|
+
hash["hashSymbol"],
|
176
189
|
)
|
177
190
|
obj
|
178
191
|
end
|
@@ -183,7 +196,7 @@ module Presto::Client
|
|
183
196
|
def decode(hash)
|
184
197
|
obj = allocate
|
185
198
|
obj.send(:initialize_struct,
|
186
|
-
hash["bufferId"],
|
199
|
+
hash["bufferId"] && TaskId.new(hash["bufferId"]),
|
187
200
|
hash["finished"],
|
188
201
|
hash["bufferedPages"],
|
189
202
|
hash["pagesSent"],
|
@@ -192,13 +205,27 @@ module Presto::Client
|
|
192
205
|
end
|
193
206
|
end
|
194
207
|
|
208
|
+
class << ClientTypeSignature =
|
209
|
+
Base.new(:raw_type, :type_arguments, :literal_arguments)
|
210
|
+
def decode(hash)
|
211
|
+
obj = allocate
|
212
|
+
obj.send(:initialize_struct,
|
213
|
+
hash["rawType"],
|
214
|
+
hash["typeArguments"] && hash["typeArguments"].map {|h| ClientTypeSignature.decode(h) },
|
215
|
+
hash["literalArguments"],
|
216
|
+
)
|
217
|
+
obj
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
195
221
|
class << Column =
|
196
|
-
Base.new(:name, :type)
|
222
|
+
Base.new(:name, :type, :type_signature)
|
197
223
|
def decode(hash)
|
198
224
|
obj = allocate
|
199
225
|
obj.send(:initialize_struct,
|
200
226
|
hash["name"],
|
201
227
|
hash["type"],
|
228
|
+
hash["typeSignature"] && ClientTypeSignature.decode(hash["typeSignature"]),
|
202
229
|
)
|
203
230
|
obj
|
204
231
|
end
|
@@ -217,13 +244,14 @@ module Presto::Client
|
|
217
244
|
end
|
218
245
|
|
219
246
|
class << DistinctLimitNode =
|
220
|
-
Base.new(:id, :source, :limit)
|
247
|
+
Base.new(:id, :source, :limit, :hash_symbol)
|
221
248
|
def decode(hash)
|
222
249
|
obj = allocate
|
223
250
|
obj.send(:initialize_struct,
|
224
251
|
hash["id"] && PlanNodeId.new(hash["id"]),
|
225
252
|
hash["source"] && PlanNode.decode(hash["source"]),
|
226
253
|
hash["limit"],
|
254
|
+
hash["hashSymbol"],
|
227
255
|
)
|
228
256
|
obj
|
229
257
|
end
|
@@ -282,13 +310,17 @@ module Presto::Client
|
|
282
310
|
end
|
283
311
|
|
284
312
|
class << ExchangeNode =
|
285
|
-
Base.new(:id, :
|
313
|
+
Base.new(:id, :type, :partition_keys, :hash_symbol, :sources, :outputs, :inputs)
|
286
314
|
def decode(hash)
|
287
315
|
obj = allocate
|
288
316
|
obj.send(:initialize_struct,
|
289
317
|
hash["id"] && PlanNodeId.new(hash["id"]),
|
290
|
-
hash["
|
318
|
+
hash["type"],
|
319
|
+
hash["partitionKeys"],
|
320
|
+
hash["hashSymbol"],
|
321
|
+
hash["sources"] && hash["sources"].map {|h| PlanNode.decode(h) },
|
291
322
|
hash["outputs"],
|
323
|
+
hash["inputs"],
|
292
324
|
)
|
293
325
|
obj
|
294
326
|
end
|
@@ -353,7 +385,7 @@ module Presto::Client
|
|
353
385
|
end
|
354
386
|
|
355
387
|
class << IndexJoinNode =
|
356
|
-
Base.new(:id, :type, :probe_source, :index_source, :criteria)
|
388
|
+
Base.new(:id, :type, :probe_source, :index_source, :criteria, :probe_hash_symbol, :index_hash_symbol)
|
357
389
|
def decode(hash)
|
358
390
|
obj = allocate
|
359
391
|
obj.send(:initialize_struct,
|
@@ -362,6 +394,8 @@ module Presto::Client
|
|
362
394
|
hash["probeSource"] && PlanNode.decode(hash["probeSource"]),
|
363
395
|
hash["indexSource"] && PlanNode.decode(hash["indexSource"]),
|
364
396
|
hash["criteria"] && hash["criteria"].map {|h| EquiJoinClause.decode(h) },
|
397
|
+
hash["probeHashSymbol"],
|
398
|
+
hash["indexHashSymbol"],
|
365
399
|
)
|
366
400
|
obj
|
367
401
|
end
|
@@ -397,8 +431,20 @@ module Presto::Client
|
|
397
431
|
end
|
398
432
|
end
|
399
433
|
|
434
|
+
class << InsertTableHandle =
|
435
|
+
Base.new(:connector_id, :connector_handle)
|
436
|
+
def decode(hash)
|
437
|
+
obj = allocate
|
438
|
+
obj.send(:initialize_struct,
|
439
|
+
hash["connectorId"],
|
440
|
+
hash["connectorHandle"],
|
441
|
+
)
|
442
|
+
obj
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
400
446
|
class << JoinNode =
|
401
|
-
Base.new(:id, :type, :left, :right, :criteria)
|
447
|
+
Base.new(:id, :type, :left, :right, :criteria, :left_hash_symbol, :right_hash_symbol)
|
402
448
|
def decode(hash)
|
403
449
|
obj = allocate
|
404
450
|
obj.send(:initialize_struct,
|
@@ -407,27 +453,28 @@ module Presto::Client
|
|
407
453
|
hash["left"] && PlanNode.decode(hash["left"]),
|
408
454
|
hash["right"] && PlanNode.decode(hash["right"]),
|
409
455
|
hash["criteria"] && hash["criteria"].map {|h| EquiJoinClause.decode(h) },
|
456
|
+
hash["leftHashSymbol"],
|
457
|
+
hash["rightHashSymbol"],
|
410
458
|
)
|
411
459
|
obj
|
412
460
|
end
|
413
461
|
end
|
414
462
|
|
415
463
|
class << LimitNode =
|
416
|
-
Base.new(:id, :source, :count
|
464
|
+
Base.new(:id, :source, :count)
|
417
465
|
def decode(hash)
|
418
466
|
obj = allocate
|
419
467
|
obj.send(:initialize_struct,
|
420
468
|
hash["id"] && PlanNodeId.new(hash["id"]),
|
421
469
|
hash["source"] && PlanNode.decode(hash["source"]),
|
422
470
|
hash["count"],
|
423
|
-
hash["sampleWeight"],
|
424
471
|
)
|
425
472
|
obj
|
426
473
|
end
|
427
474
|
end
|
428
475
|
|
429
476
|
class << MarkDistinctNode =
|
430
|
-
Base.new(:id, :source, :marker_symbol, :distinct_symbols, :
|
477
|
+
Base.new(:id, :source, :marker_symbol, :distinct_symbols, :hash_symbol)
|
431
478
|
def decode(hash)
|
432
479
|
obj = allocate
|
433
480
|
obj.send(:initialize_struct,
|
@@ -435,20 +482,7 @@ module Presto::Client
|
|
435
482
|
hash["source"] && PlanNode.decode(hash["source"]),
|
436
483
|
hash["markerSymbol"],
|
437
484
|
hash["distinctSymbols"],
|
438
|
-
hash["
|
439
|
-
)
|
440
|
-
obj
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
class << MaterializeSampleNode =
|
445
|
-
Base.new(:id, :source, :sample_weight_symbol)
|
446
|
-
def decode(hash)
|
447
|
-
obj = allocate
|
448
|
-
obj.send(:initialize_struct,
|
449
|
-
hash["id"] && PlanNodeId.new(hash["id"]),
|
450
|
-
hash["source"] && PlanNode.decode(hash["source"]),
|
451
|
-
hash["sampleWeightSymbol"],
|
485
|
+
hash["hashSymbol"],
|
452
486
|
)
|
453
487
|
obj
|
454
488
|
end
|
@@ -512,7 +546,7 @@ module Presto::Client
|
|
512
546
|
end
|
513
547
|
|
514
548
|
class << PipelineStats =
|
515
|
-
Base.new(:input_pipeline, :output_pipeline, :total_drivers, :queued_drivers, :running_drivers, :completed_drivers, :memory_reservation, :queued_time, :elapsed_time, :total_scheduled_time, :total_cpu_time, :total_user_time, :total_blocked_time, :raw_input_data_size, :raw_input_positions, :processed_input_data_size, :processed_input_positions, :output_data_size, :output_positions, :operator_summaries, :drivers)
|
549
|
+
Base.new(:input_pipeline, :output_pipeline, :total_drivers, :queued_drivers, :queued_partitioned_drivers, :running_drivers, :running_partitioned_drivers, :completed_drivers, :memory_reservation, :queued_time, :elapsed_time, :total_scheduled_time, :total_cpu_time, :total_user_time, :total_blocked_time, :raw_input_data_size, :raw_input_positions, :processed_input_data_size, :processed_input_positions, :output_data_size, :output_positions, :operator_summaries, :drivers)
|
516
550
|
def decode(hash)
|
517
551
|
obj = allocate
|
518
552
|
obj.send(:initialize_struct,
|
@@ -520,7 +554,9 @@ module Presto::Client
|
|
520
554
|
hash["outputPipeline"],
|
521
555
|
hash["totalDrivers"],
|
522
556
|
hash["queuedDrivers"],
|
557
|
+
hash["queuedPartitionedDrivers"],
|
523
558
|
hash["runningDrivers"],
|
559
|
+
hash["runningPartitionedDrivers"],
|
524
560
|
hash["completedDrivers"],
|
525
561
|
hash["memoryReservation"],
|
526
562
|
hash["queuedTime"] && DistributionSnapshot.decode(hash["queuedTime"]),
|
@@ -543,17 +579,19 @@ module Presto::Client
|
|
543
579
|
end
|
544
580
|
|
545
581
|
class << PlanFragment =
|
546
|
-
Base.new(:id, :root, :symbols, :distribution, :partitioned_source, :output_partitioning, :partition_by)
|
582
|
+
Base.new(:id, :root, :symbols, :output_layout, :distribution, :partitioned_source, :output_partitioning, :partition_by, :hash)
|
547
583
|
def decode(hash)
|
548
584
|
obj = allocate
|
549
585
|
obj.send(:initialize_struct,
|
550
586
|
hash["id"] && PlanFragmentId.new(hash["id"]),
|
551
587
|
hash["root"] && PlanNode.decode(hash["root"]),
|
552
588
|
hash["symbols"],
|
589
|
+
hash["outputLayout"],
|
553
590
|
hash["distribution"] && hash["distribution"].downcase.to_sym,
|
554
591
|
hash["partitionedSource"] && PlanNodeId.new(hash["partitionedSource"]),
|
555
592
|
hash["outputPartitioning"] && hash["outputPartitioning"].downcase.to_sym,
|
556
593
|
hash["partitionBy"],
|
594
|
+
hash["hash"],
|
557
595
|
)
|
558
596
|
obj
|
559
597
|
end
|
@@ -588,17 +626,21 @@ module Presto::Client
|
|
588
626
|
end
|
589
627
|
|
590
628
|
class << QueryInfo =
|
591
|
-
Base.new(:query_id, :session, :state, :self, :field_names, :query, :query_stats, :output_stage, :failure_info, :error_code, :inputs)
|
629
|
+
Base.new(:query_id, :session, :state, :scheduled, :self, :field_names, :query, :query_stats, :set_session_properties, :reset_session_properties, :update_type, :output_stage, :failure_info, :error_code, :inputs)
|
592
630
|
def decode(hash)
|
593
631
|
obj = allocate
|
594
632
|
obj.send(:initialize_struct,
|
595
633
|
hash["queryId"] && QueryId.new(hash["queryId"]),
|
596
|
-
hash["session"] &&
|
634
|
+
hash["session"] && Session.decode(hash["session"]),
|
597
635
|
hash["state"] && hash["state"].downcase.to_sym,
|
636
|
+
hash["scheduled"],
|
598
637
|
hash["self"],
|
599
638
|
hash["fieldNames"],
|
600
639
|
hash["query"],
|
601
640
|
hash["queryStats"] && QueryStats.decode(hash["queryStats"]),
|
641
|
+
hash["setSessionProperties"],
|
642
|
+
hash["resetSessionProperties"],
|
643
|
+
hash["updateType"],
|
602
644
|
hash["outputStage"] && StageInfo.decode(hash["outputStage"]),
|
603
645
|
hash["failureInfo"] && FailureInfo.decode(hash["failureInfo"]),
|
604
646
|
hash["errorCode"] && ErrorCode.decode(hash["errorCode"]),
|
@@ -609,7 +651,7 @@ module Presto::Client
|
|
609
651
|
end
|
610
652
|
|
611
653
|
class << QueryResults =
|
612
|
-
Base.new(:id, :info_uri, :partial_cancel_uri, :next_uri, :columns, :data, :stats, :error)
|
654
|
+
Base.new(:id, :info_uri, :partial_cancel_uri, :next_uri, :columns, :data, :stats, :error, :update_type, :update_count)
|
613
655
|
def decode(hash)
|
614
656
|
obj = allocate
|
615
657
|
obj.send(:initialize_struct,
|
@@ -621,6 +663,8 @@ module Presto::Client
|
|
621
663
|
hash["data"],
|
622
664
|
hash["stats"] && StatementStats.decode(hash["stats"]),
|
623
665
|
hash["error"] && QueryError.decode(hash["error"]),
|
666
|
+
hash["updateType"],
|
667
|
+
hash["updateCount"],
|
624
668
|
)
|
625
669
|
obj
|
626
670
|
end
|
@@ -663,6 +707,19 @@ module Presto::Client
|
|
663
707
|
end
|
664
708
|
end
|
665
709
|
|
710
|
+
class << RemoteSourceNode =
|
711
|
+
Base.new(:id, :source_fragment_ids, :outputs)
|
712
|
+
def decode(hash)
|
713
|
+
obj = allocate
|
714
|
+
obj.send(:initialize_struct,
|
715
|
+
hash["id"] && PlanNodeId.new(hash["id"]),
|
716
|
+
hash["sourceFragmentIds"] && hash["sourceFragmentIds"].map {|h| PlanFragmentId.new(h) },
|
717
|
+
hash["outputs"],
|
718
|
+
)
|
719
|
+
obj
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
666
723
|
class << SampleNode =
|
667
724
|
Base.new(:id, :source, :sample_ratio, :sample_type, :rescaled, :sample_weight_symbol)
|
668
725
|
def decode(hash)
|
@@ -680,7 +737,7 @@ module Presto::Client
|
|
680
737
|
end
|
681
738
|
|
682
739
|
class << SemiJoinNode =
|
683
|
-
Base.new(:id, :source, :filtering_source, :source_join_symbol, :filtering_source_join_symbol, :semi_join_output)
|
740
|
+
Base.new(:id, :source, :filtering_source, :source_join_symbol, :filtering_source_join_symbol, :semi_join_output, :source_hash_symbol, :filtering_source_hash_symbol)
|
684
741
|
def decode(hash)
|
685
742
|
obj = allocate
|
686
743
|
obj.send(:initialize_struct,
|
@@ -690,6 +747,29 @@ module Presto::Client
|
|
690
747
|
hash["sourceJoinSymbol"],
|
691
748
|
hash["filteringSourceJoinSymbol"],
|
692
749
|
hash["semiJoinOutput"],
|
750
|
+
hash["sourceHashSymbol"],
|
751
|
+
hash["filteringSourceHashSymbol"],
|
752
|
+
)
|
753
|
+
obj
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
757
|
+
class << Session =
|
758
|
+
Base.new(:user, :source, :catalog, :schema, :time_zone_key, :locale, :remote_user_address, :user_agent, :start_time, :system_properties, :catalog_properties)
|
759
|
+
def decode(hash)
|
760
|
+
obj = allocate
|
761
|
+
obj.send(:initialize_struct,
|
762
|
+
hash["user"],
|
763
|
+
hash["source"],
|
764
|
+
hash["catalog"],
|
765
|
+
hash["schema"],
|
766
|
+
hash["timeZoneKey"],
|
767
|
+
hash["locale"],
|
768
|
+
hash["remoteUserAddress"],
|
769
|
+
hash["userAgent"],
|
770
|
+
hash["startTime"],
|
771
|
+
hash["systemProperties"],
|
772
|
+
hash["catalogProperties"],
|
693
773
|
)
|
694
774
|
obj
|
695
775
|
end
|
@@ -710,27 +790,16 @@ module Presto::Client
|
|
710
790
|
end
|
711
791
|
|
712
792
|
class << Signature =
|
713
|
-
Base.new(:name, :return_type, :argument_types, :
|
793
|
+
Base.new(:name, :type_parameters, :return_type, :argument_types, :variable_arity, :internal)
|
714
794
|
def decode(hash)
|
715
795
|
obj = allocate
|
716
796
|
obj.send(:initialize_struct,
|
717
797
|
hash["name"],
|
798
|
+
hash["typeParameters"] && hash["typeParameters"].map {|h| TypeParameter.decode(h) },
|
718
799
|
hash["returnType"],
|
719
800
|
hash["argumentTypes"],
|
720
|
-
hash["
|
721
|
-
|
722
|
-
obj
|
723
|
-
end
|
724
|
-
end
|
725
|
-
|
726
|
-
class << SinkNode =
|
727
|
-
Base.new(:id, :source, :output_symbols)
|
728
|
-
def decode(hash)
|
729
|
-
obj = allocate
|
730
|
-
obj.send(:initialize_struct,
|
731
|
-
hash["id"] && PlanNodeId.new(hash["id"]),
|
732
|
-
hash["source"] && PlanNode.decode(hash["source"]),
|
733
|
-
hash["outputSymbols"],
|
801
|
+
hash["variableArity"],
|
802
|
+
hash["internal"],
|
734
803
|
)
|
735
804
|
obj
|
736
805
|
end
|
@@ -823,7 +892,7 @@ module Presto::Client
|
|
823
892
|
obj.send(:initialize_struct,
|
824
893
|
hash["id"] && PlanNodeId.new(hash["id"]),
|
825
894
|
hash["source"] && PlanNode.decode(hash["source"]),
|
826
|
-
hash["target"] &&
|
895
|
+
hash["target"] && WriterTarget.decode(hash["target"]),
|
827
896
|
hash["outputs"],
|
828
897
|
)
|
829
898
|
obj
|
@@ -864,7 +933,7 @@ module Presto::Client
|
|
864
933
|
obj.send(:initialize_struct,
|
865
934
|
hash["id"] && PlanNodeId.new(hash["id"]),
|
866
935
|
hash["source"] && PlanNode.decode(hash["source"]),
|
867
|
-
hash["target"] &&
|
936
|
+
hash["target"] && WriterTarget.decode(hash["target"]),
|
868
937
|
hash["columns"],
|
869
938
|
hash["columnNames"],
|
870
939
|
hash["outputs"],
|
@@ -875,11 +944,12 @@ module Presto::Client
|
|
875
944
|
end
|
876
945
|
|
877
946
|
class << TaskInfo =
|
878
|
-
Base.new(:task_id, :version, :state, :self, :last_heartbeat, :output_buffers, :no_more_splits, :stats, :failures)
|
947
|
+
Base.new(:task_id, :node_instance_id, :version, :state, :self, :last_heartbeat, :output_buffers, :no_more_splits, :stats, :failures)
|
879
948
|
def decode(hash)
|
880
949
|
obj = allocate
|
881
950
|
obj.send(:initialize_struct,
|
882
951
|
hash["taskId"] && TaskId.new(hash["taskId"]),
|
952
|
+
hash["nodeInstanceId"],
|
883
953
|
hash["version"],
|
884
954
|
hash["state"] && hash["state"].downcase.to_sym,
|
885
955
|
hash["self"],
|
@@ -894,7 +964,7 @@ module Presto::Client
|
|
894
964
|
end
|
895
965
|
|
896
966
|
class << TaskStats =
|
897
|
-
Base.new(:create_time, :first_start_time, :last_start_time, :end_time, :elapsed_time, :queued_time, :total_drivers, :queued_drivers, :running_drivers, :completed_drivers, :memory_reservation, :total_scheduled_time, :total_cpu_time, :total_user_time, :total_blocked_time, :raw_input_data_size, :raw_input_positions, :processed_input_data_size, :processed_input_positions, :output_data_size, :output_positions, :pipelines)
|
967
|
+
Base.new(:create_time, :first_start_time, :last_start_time, :end_time, :elapsed_time, :queued_time, :total_drivers, :queued_drivers, :queued_partitioned_drivers, :running_drivers, :running_partitioned_drivers, :completed_drivers, :memory_reservation, :total_scheduled_time, :total_cpu_time, :total_user_time, :total_blocked_time, :raw_input_data_size, :raw_input_positions, :processed_input_data_size, :processed_input_positions, :output_data_size, :output_positions, :pipelines)
|
898
968
|
def decode(hash)
|
899
969
|
obj = allocate
|
900
970
|
obj.send(:initialize_struct,
|
@@ -906,7 +976,9 @@ module Presto::Client
|
|
906
976
|
hash["queuedTime"],
|
907
977
|
hash["totalDrivers"],
|
908
978
|
hash["queuedDrivers"],
|
979
|
+
hash["queuedPartitionedDrivers"],
|
909
980
|
hash["runningDrivers"],
|
981
|
+
hash["runningPartitionedDrivers"],
|
910
982
|
hash["completedDrivers"],
|
911
983
|
hash["memoryReservation"],
|
912
984
|
hash["totalScheduledTime"],
|
@@ -926,7 +998,7 @@ module Presto::Client
|
|
926
998
|
end
|
927
999
|
|
928
1000
|
class << TopNNode =
|
929
|
-
Base.new(:id, :source, :count, :order_by, :orderings, :partial
|
1001
|
+
Base.new(:id, :source, :count, :order_by, :orderings, :partial)
|
930
1002
|
def decode(hash)
|
931
1003
|
obj = allocate
|
932
1004
|
obj.send(:initialize_struct,
|
@@ -936,7 +1008,20 @@ module Presto::Client
|
|
936
1008
|
hash["orderBy"],
|
937
1009
|
hash["orderings"] && Hash[hash["orderings"].to_a.map! {|k,v| [k, v.downcase.to_sym] }],
|
938
1010
|
hash["partial"],
|
939
|
-
|
1011
|
+
)
|
1012
|
+
obj
|
1013
|
+
end
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
class << TypeParameter =
|
1017
|
+
Base.new(:name, :comparable_required, :orderable_required, :variadic_bound)
|
1018
|
+
def decode(hash)
|
1019
|
+
obj = allocate
|
1020
|
+
obj.send(:initialize_struct,
|
1021
|
+
hash["name"],
|
1022
|
+
hash["comparableRequired"],
|
1023
|
+
hash["orderableRequired"],
|
1024
|
+
hash["variadicBound"],
|
940
1025
|
)
|
941
1026
|
obj
|
942
1027
|
end
|
@@ -956,7 +1041,7 @@ module Presto::Client
|
|
956
1041
|
end
|
957
1042
|
|
958
1043
|
class << WindowNode =
|
959
|
-
Base.new(:id, :source, :partition_by, :order_by, :orderings, :window_functions, :signatures)
|
1044
|
+
Base.new(:id, :source, :partition_by, :order_by, :orderings, :frame, :window_functions, :signatures, :hash_symbol)
|
960
1045
|
def decode(hash)
|
961
1046
|
obj = allocate
|
962
1047
|
obj.send(:initialize_struct,
|
@@ -965,8 +1050,10 @@ module Presto::Client
|
|
965
1050
|
hash["partitionBy"],
|
966
1051
|
hash["orderBy"],
|
967
1052
|
hash["orderings"] && Hash[hash["orderings"].to_a.map! {|k,v| [k, v.downcase.to_sym] }],
|
1053
|
+
hash["frame"],
|
968
1054
|
hash["windowFunctions"],
|
969
1055
|
hash["signatures"] && Hash[hash["signatures"].to_a.map! {|k,v| [k, Signature.decode(v)] }],
|
1056
|
+
hash["hashSymbol"],
|
970
1057
|
)
|
971
1058
|
obj
|
972
1059
|
end
|
data/modelgen/modelgen.rb
CHANGED
@@ -10,13 +10,13 @@ require_relative 'presto_models'
|
|
10
10
|
require 'erb'
|
11
11
|
erb = ERB.new(File.read(template_path))
|
12
12
|
|
13
|
-
source_path =
|
13
|
+
source_path = source_dir
|
14
14
|
|
15
15
|
predefined_simple_classes = %w[QueryId StageId TaskId PlanNodeId PlanFragmentId ConnectorSession]
|
16
|
-
predefined_models = %w[DistributionSnapshot PlanNode EquiJoinClause]
|
16
|
+
predefined_models = %w[DistributionSnapshot PlanNode EquiJoinClause WriterTarget]
|
17
17
|
|
18
|
-
assume_primitive = %w[Object Type Symbol URI Duration DataSize DateTime ConnectorTableHandle ConnectorOutputTableHandle ConnectorIndexHandle ConnectorColumnHandle Expression FunctionCall]
|
19
|
-
enum_types = %w[QueryState StageState TaskState QueueState PlanDistribution OutputPartitioning Step SortOrder]
|
18
|
+
assume_primitive = %w[Object Type Long Symbol URI Duration DataSize DateTime ConnectorTableHandle ConnectorOutputTableHandle ConnectorIndexHandle ConnectorColumnHandle ConnectorInsertTableHandle Expression FunctionCall TimeZoneKey Locale TypeSignature Frame]
|
19
|
+
enum_types = %w[QueryState StageState TaskState QueueState PlanDistribution OutputPartitioning Step SortOrder BufferState]
|
20
20
|
|
21
21
|
root_models = %w[QueryResults QueryInfo] + %w[
|
22
22
|
OutputNode
|
@@ -25,7 +25,6 @@ TableScanNode
|
|
25
25
|
ValuesNode
|
26
26
|
AggregationNode
|
27
27
|
MarkDistinctNode
|
28
|
-
MaterializeSampleNode
|
29
28
|
FilterNode
|
30
29
|
WindowNode
|
31
30
|
LimitNode
|
@@ -34,14 +33,14 @@ TopNNode
|
|
34
33
|
SampleNode
|
35
34
|
SortNode
|
36
35
|
ExchangeNode
|
37
|
-
|
36
|
+
RemoteSourceNode
|
38
37
|
JoinNode
|
39
38
|
SemiJoinNode
|
40
39
|
IndexJoinNode
|
41
40
|
IndexSourceNode
|
42
41
|
TableWriterNode
|
43
42
|
TableCommitNode
|
44
|
-
]
|
43
|
+
] + %w[InsertTableHandle OutputTableHandle]
|
45
44
|
|
46
45
|
analyzer = PrestoModels::ModelAnalyzer.new(
|
47
46
|
source_path,
|
data/modelgen/models.rb
CHANGED
@@ -102,7 +102,7 @@ module Presto::Client
|
|
102
102
|
when "sample" then SampleNode
|
103
103
|
when "sort" then SortNode
|
104
104
|
when "exchange" then ExchangeNode
|
105
|
-
when "
|
105
|
+
when "remoteSource" then RemoteSourceNode
|
106
106
|
when "join" then JoinNode
|
107
107
|
when "INNER" then JoinNode
|
108
108
|
when "LEFT" then JoinNode
|
@@ -155,6 +155,18 @@ module Presto::Client
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
+
class << WriterTarget =
|
159
|
+
Base.new(:type, :handle)
|
160
|
+
def decode(hash)
|
161
|
+
obj = allocate
|
162
|
+
obj.send(:initialize_struct,
|
163
|
+
hash["type"],
|
164
|
+
hash["type"] == 'InsertHandle' ? InsertTableHandle.decode(hash['handle']) : OutputTableHandle.decode(hash['handle'])
|
165
|
+
)
|
166
|
+
obj
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
158
170
|
##
|
159
171
|
# Those model classes are automatically generated
|
160
172
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: presto-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- modelgen/models.rb
|
111
111
|
- modelgen/presto_models.rb
|
112
112
|
- presto-client.gemspec
|
113
|
-
- presto-client.rb
|
114
113
|
- spec/spec_helper.rb
|
115
114
|
- spec/statement_client_spec.rb
|
116
115
|
homepage: https://github.com/treasure-data/presto-client-ruby
|
@@ -140,3 +139,4 @@ summary: Presto client library
|
|
140
139
|
test_files:
|
141
140
|
- spec/spec_helper.rb
|
142
141
|
- spec/statement_client_spec.rb
|
142
|
+
has_rdoc: false
|
data/presto-client.rb
DELETED
@@ -1,420 +0,0 @@
|
|
1
|
-
|
2
|
-
module PrestoClient
|
3
|
-
VERSION = "0.1.0"
|
4
|
-
|
5
|
-
require 'faraday'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
class ClientSession
|
9
|
-
def initialize(options)
|
10
|
-
@server = options[:server]
|
11
|
-
@user = options[:user]
|
12
|
-
@source = options[:source]
|
13
|
-
@catalog = options[:catalog]
|
14
|
-
@schema = options[:schema]
|
15
|
-
@debug = !!options[:debug]
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :server
|
19
|
-
attr_reader :user
|
20
|
-
attr_reader :source
|
21
|
-
attr_reader :catalog
|
22
|
-
attr_reader :schema
|
23
|
-
|
24
|
-
def debug?
|
25
|
-
@debug
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
#class StageStats
|
30
|
-
# attr_reader :stage_id
|
31
|
-
# attr_reader :state
|
32
|
-
# attr_reader :done
|
33
|
-
# attr_reader :nodes
|
34
|
-
# attr_reader :total_splits
|
35
|
-
# attr_reader :queued_splits
|
36
|
-
# attr_reader :running_splits
|
37
|
-
# attr_reader :completed_splits
|
38
|
-
# attr_reader :user_time_millis
|
39
|
-
# attr_reader :cpu_time_millis
|
40
|
-
# attr_reader :wall_time_millis
|
41
|
-
# attr_reader :processed_rows
|
42
|
-
# attr_reader :processed_bytes
|
43
|
-
# attr_reader :sub_stages
|
44
|
-
#
|
45
|
-
# def initialize(options={})
|
46
|
-
# @stage_id = options[:stage_id]
|
47
|
-
# @state = options[:state]
|
48
|
-
# @done = options[:done]
|
49
|
-
# @nodes = options[:nodes]
|
50
|
-
# @total_splits = options[:total_splits]
|
51
|
-
# @queued_splits = options[:queued_splits]
|
52
|
-
# @running_splits = options[:running_splits]
|
53
|
-
# @completed_splits = options[:completed_splits]
|
54
|
-
# @user_time_millis = options[:user_time_millis]
|
55
|
-
# @cpu_time_millis = options[:cpu_time_millis]
|
56
|
-
# @wall_time_millis = options[:wall_time_millis]
|
57
|
-
# @processed_rows = options[:processed_rows]
|
58
|
-
# @processed_bytes = options[:processed_bytes]
|
59
|
-
# @sub_stages = options[:sub_stages]
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# def self.decode_hash(hash)
|
63
|
-
# new(
|
64
|
-
# stage_id: hash["stageId"],
|
65
|
-
# state: hash["state"],
|
66
|
-
# done: hash["done"],
|
67
|
-
# nodes: hash["nodes"],
|
68
|
-
# total_splits: hash["totalSplits"],
|
69
|
-
# queued_splits: hash["queuedSplits"],
|
70
|
-
# running_splits: hash["runningSplits"],
|
71
|
-
# completed_splits: hash["completedSplits"],
|
72
|
-
# user_time_millis: hash["userTimeMillis"],
|
73
|
-
# cpu_time_millis: hash["cpuTimeMillis"],
|
74
|
-
# wall_time_millis: hash["wallTimeMillis"],
|
75
|
-
# processed_rows: hash["processedRows"],
|
76
|
-
# processed_bytes: hash["processedBytes"],
|
77
|
-
# sub_stages: hash["subStages"].map {|h| StageStats.decode_hash(h) },
|
78
|
-
# )
|
79
|
-
# end
|
80
|
-
#end
|
81
|
-
|
82
|
-
class StatementStats
|
83
|
-
attr_reader :state
|
84
|
-
attr_reader :scheduled
|
85
|
-
attr_reader :nodes
|
86
|
-
attr_reader :total_splits
|
87
|
-
attr_reader :queued_splits
|
88
|
-
attr_reader :running_splits
|
89
|
-
attr_reader :completed_splits
|
90
|
-
attr_reader :user_time_millis
|
91
|
-
attr_reader :cpu_time_millis
|
92
|
-
attr_reader :wall_time_millis
|
93
|
-
attr_reader :processed_rows
|
94
|
-
attr_reader :processed_bytes
|
95
|
-
#attr_reader :root_stage
|
96
|
-
|
97
|
-
def initialize(options={})
|
98
|
-
@state = state
|
99
|
-
@scheduled = scheduled
|
100
|
-
@nodes = nodes
|
101
|
-
@total_splits = total_splits
|
102
|
-
@queued_splits = queued_splits
|
103
|
-
@running_splits = running_splits
|
104
|
-
@completed_splits = completed_splits
|
105
|
-
@user_time_millis = user_time_millis
|
106
|
-
@cpu_time_millis = cpu_time_millis
|
107
|
-
@wall_time_millis = wall_time_millis
|
108
|
-
@processed_rows = processed_rows
|
109
|
-
@processed_bytes = processed_bytes
|
110
|
-
#@root_stage = root_stage
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.decode_hash(hash)
|
114
|
-
new(
|
115
|
-
state: hash["state"],
|
116
|
-
scheduled: hash["scheduled"],
|
117
|
-
nodes: hash["nodes"],
|
118
|
-
total_splits: hash["totalSplits"],
|
119
|
-
queued_splits: hash["queuedSplits"],
|
120
|
-
running_splits: hash["runningSplits"],
|
121
|
-
completed_splits: hash["completedSplits"],
|
122
|
-
user_time_millis: hash["userTimeMillis"],
|
123
|
-
cpu_time_millis: hash["cpuTimeMillis"],
|
124
|
-
wall_time_millis: hash["wallTimeMillis"],
|
125
|
-
processed_rows: hash["processedRows"],
|
126
|
-
processed_bytes: hash["processedBytes"],
|
127
|
-
#root_stage: StageStats.decode_hash(hash["rootStage"]),
|
128
|
-
)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
class Column
|
133
|
-
attr_reader :name
|
134
|
-
attr_reader :type
|
135
|
-
|
136
|
-
def initialize(options={})
|
137
|
-
@name = options[:name]
|
138
|
-
@type = options[:type]
|
139
|
-
end
|
140
|
-
|
141
|
-
def self.decode_hash(hash)
|
142
|
-
new(
|
143
|
-
name: hash["name"],
|
144
|
-
type: hash["type"],
|
145
|
-
)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
class QueryResults
|
150
|
-
attr_reader :id
|
151
|
-
attr_reader :info_uri
|
152
|
-
attr_reader :partial_cache_uri
|
153
|
-
attr_reader :next_uri
|
154
|
-
attr_reader :columns
|
155
|
-
attr_reader :data
|
156
|
-
attr_reader :stats
|
157
|
-
attr_reader :error
|
158
|
-
|
159
|
-
def initialize(options={})
|
160
|
-
@id = options[:id]
|
161
|
-
@info_uri = options[:info_uri]
|
162
|
-
@partial_cache_uri = options[:partial_cache_uri]
|
163
|
-
@next_uri = options[:next_uri]
|
164
|
-
@columns = options[:columns]
|
165
|
-
@data = options[:data]
|
166
|
-
@stats = options[:stats]
|
167
|
-
@error = options[:error]
|
168
|
-
end
|
169
|
-
|
170
|
-
def self.decode_hash(hash)
|
171
|
-
new(
|
172
|
-
id: hash["id"],
|
173
|
-
info_uri: hash["infoUri"],
|
174
|
-
partial_cache_uri: hash["partialCancelUri"],
|
175
|
-
next_uri: hash["nextUri"],
|
176
|
-
columns: hash["columns"] ? hash["columns"].map {|h| Column.decode_hash(h) } : nil,
|
177
|
-
data: hash["data"]
|
178
|
-
stats: StatementStats.decode_hash(hash["stats"]),
|
179
|
-
error: hash["error"], # TODO
|
180
|
-
)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
module PrestoHeaders
|
185
|
-
PRESTO_USER = "X-Presto-User"
|
186
|
-
PRESTO_SOURCE = "X-Presto-Source"
|
187
|
-
PRESTO_CATALOG = "X-Presto-Catalog"
|
188
|
-
PRESTO_SCHEMA = "X-Presto-Schema"
|
189
|
-
|
190
|
-
PRESTO_CURRENT_STATE = "X-Presto-Current-State"
|
191
|
-
PRESTO_MAX_WAIT = "X-Presto-Max-Wait"
|
192
|
-
PRESTO_MAX_SIZE = "X-Presto-Max-Size"
|
193
|
-
PRESTO_PAGE_SEQUENCE_ID = "X-Presto-Page-Sequence-Id"
|
194
|
-
end
|
195
|
-
|
196
|
-
class StatementClient
|
197
|
-
HEADERS = {
|
198
|
-
"User-Agent" => "presto-ruby/#{VERSION}"
|
199
|
-
}
|
200
|
-
|
201
|
-
def initialize(faraday, session, query)
|
202
|
-
@faraday = faraday
|
203
|
-
@faraday.headers.merge!(HEADERS)
|
204
|
-
|
205
|
-
@session = session
|
206
|
-
@query = query
|
207
|
-
@closed = false
|
208
|
-
@exception = nil
|
209
|
-
post_query_request!
|
210
|
-
end
|
211
|
-
|
212
|
-
def post_query_request!
|
213
|
-
response = @faraday.post do |req|
|
214
|
-
req.url "/v1/statement"
|
215
|
-
|
216
|
-
if v = @session.user
|
217
|
-
req.headers[PrestoHeaders::PRESTO_USER] = v
|
218
|
-
end
|
219
|
-
if v = @session.source
|
220
|
-
req.headers[PrestoHeaders::PRESTO_SOURCE] = v
|
221
|
-
end
|
222
|
-
if catalog = @session.catalog
|
223
|
-
req.headers[PrestoHeaders::PRESTO_CATALOG] = catalog
|
224
|
-
end
|
225
|
-
if v = @session.schema
|
226
|
-
req.headers[PrestoHeaders::PRESTO_SCHEMA] = v
|
227
|
-
end
|
228
|
-
|
229
|
-
req.body = @query
|
230
|
-
end
|
231
|
-
|
232
|
-
# TODO error handling
|
233
|
-
if response.status != 200
|
234
|
-
raise "Failed to start query: #{response.body}" # TODO error class
|
235
|
-
end
|
236
|
-
|
237
|
-
body = response.body
|
238
|
-
hash = JSON.parse(body)
|
239
|
-
@results = QueryResults.decode_hash(hash)
|
240
|
-
end
|
241
|
-
|
242
|
-
private :post_query_request!
|
243
|
-
|
244
|
-
attr_reader :query
|
245
|
-
|
246
|
-
def debug?
|
247
|
-
@session.debug?
|
248
|
-
end
|
249
|
-
|
250
|
-
def closed?
|
251
|
-
@closed
|
252
|
-
end
|
253
|
-
|
254
|
-
attr_reader :exception
|
255
|
-
|
256
|
-
def exception?
|
257
|
-
@exception
|
258
|
-
end
|
259
|
-
|
260
|
-
def query_failed?
|
261
|
-
@results.error != nil
|
262
|
-
end
|
263
|
-
|
264
|
-
def query_succeeded?
|
265
|
-
@results.error == nil && !@exception && !@closed
|
266
|
-
end
|
267
|
-
|
268
|
-
def current_results
|
269
|
-
@results
|
270
|
-
end
|
271
|
-
|
272
|
-
def has_next?
|
273
|
-
!!@results.next_uri
|
274
|
-
end
|
275
|
-
|
276
|
-
def advance
|
277
|
-
if closed? || !has_next?
|
278
|
-
return false
|
279
|
-
end
|
280
|
-
uri = @results.next_uri
|
281
|
-
|
282
|
-
start = Time.now
|
283
|
-
attempts = 0
|
284
|
-
|
285
|
-
begin
|
286
|
-
begin
|
287
|
-
response = @faraday.get do |req|
|
288
|
-
req.url uri
|
289
|
-
end
|
290
|
-
rescue => e
|
291
|
-
@exception = e
|
292
|
-
raise @exception
|
293
|
-
end
|
294
|
-
|
295
|
-
if response.status == 200 && !response.body.to_s.empty?
|
296
|
-
@results = QueryResults.decode_hash(JSON.parse(response.body))
|
297
|
-
return true
|
298
|
-
end
|
299
|
-
|
300
|
-
if response.status != 503 # retry on 503 Service Unavailable
|
301
|
-
# deterministic error
|
302
|
-
@exception = StandardError.new("Error fetching next at #{uri} returned #{response.status}: #{response.body}") # TODO error class
|
303
|
-
raise @exception
|
304
|
-
end
|
305
|
-
|
306
|
-
attempts += 1
|
307
|
-
sleep attempts * 0.1
|
308
|
-
end while (Time.now - start) < 2*60*60 && !@closed
|
309
|
-
|
310
|
-
@exception = StandardError.new("Error fetching next") # TODO error class
|
311
|
-
raise @exception
|
312
|
-
end
|
313
|
-
|
314
|
-
def close
|
315
|
-
return if @closed
|
316
|
-
|
317
|
-
# cancel running statement
|
318
|
-
if uri = @results.next_uri
|
319
|
-
# TODO error handling
|
320
|
-
# TODO make async reqeust and ignore response
|
321
|
-
@faraday.delete do |req|
|
322
|
-
req.url uri
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
@closed = true
|
327
|
-
nil
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
class Query
|
332
|
-
def self.start(session, query)
|
333
|
-
faraday = Faraday.new(url: "http://#{session.server}") do |faraday|
|
334
|
-
faraday.request :url_encoded
|
335
|
-
faraday.response :logger
|
336
|
-
faraday.adapter Faraday.default_adapter
|
337
|
-
end
|
338
|
-
|
339
|
-
new StatementClient.new(faraday, session, query)
|
340
|
-
end
|
341
|
-
|
342
|
-
def initialize(client)
|
343
|
-
@client = client
|
344
|
-
end
|
345
|
-
|
346
|
-
def wait_for_data
|
347
|
-
while @client.has_next? && @client.current_results.data == nil
|
348
|
-
@client.advance
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
private :wait_for_data
|
353
|
-
|
354
|
-
def columns
|
355
|
-
wait_for_data
|
356
|
-
|
357
|
-
raise_error unless @client.query_succeeded?
|
358
|
-
|
359
|
-
return @client.current_results.columns
|
360
|
-
end
|
361
|
-
|
362
|
-
def each_row(&block)
|
363
|
-
wait_for_data
|
364
|
-
|
365
|
-
raise_error unless @client.query_succeeded?
|
366
|
-
|
367
|
-
if self.columns == nil
|
368
|
-
raise "Query #{@client.current_results.id} has no columns"
|
369
|
-
end
|
370
|
-
|
371
|
-
begin
|
372
|
-
if data = @client.current_results.data
|
373
|
-
data.each(&block)
|
374
|
-
end
|
375
|
-
@client.advance
|
376
|
-
end while @client.has_next?
|
377
|
-
end
|
378
|
-
|
379
|
-
def raise_error
|
380
|
-
if @client.closed?
|
381
|
-
raise "Query aborted by user"
|
382
|
-
elsif @client.exception?
|
383
|
-
raise "Query is gone: #{@client.exception}"
|
384
|
-
elsif @client.query_failed?
|
385
|
-
results = @client.current_results
|
386
|
-
# TODO error location
|
387
|
-
raise "Query #{results.id} failed: #{results.error}"
|
388
|
-
end
|
389
|
-
end
|
390
|
-
|
391
|
-
private :raise_error
|
392
|
-
end
|
393
|
-
|
394
|
-
class Client
|
395
|
-
def initialize(options)
|
396
|
-
@session = ClientSession.new(options)
|
397
|
-
end
|
398
|
-
|
399
|
-
def query(query)
|
400
|
-
Query.start(@session, query)
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
|
-
require 'pp'
|
406
|
-
|
407
|
-
client = PrestoClient::Client.new(
|
408
|
-
server: "localhost:8880",
|
409
|
-
user: "frsyuki",
|
410
|
-
catalog: "native",
|
411
|
-
schema: "default",
|
412
|
-
debug: true
|
413
|
-
)
|
414
|
-
|
415
|
-
q = client.query("select * from sys.query")
|
416
|
-
p q.columns
|
417
|
-
q.each_row {|row|
|
418
|
-
p row
|
419
|
-
}
|
420
|
-
|