presto-client 0.5.14 → 0.6.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 +4 -4
- data/ChangeLog +5 -0
- data/README.md +1 -1
- data/Rakefile +3 -1
- data/lib/presto/client/model_versions/303.rb +2574 -0
- data/lib/presto/client/model_versions/316.rb +2595 -0
- data/lib/presto/client/models.rb +3 -1
- data/lib/presto/client/query.rb +1 -1
- data/lib/presto/client/statement_client.rb +10 -7
- data/lib/presto/client/version.rb +1 -1
- data/modelgen/model_versions.rb +24 -0
- data/modelgen/modelgen.rb +16 -14
- data/modelgen/presto_models.rb +29 -9
- metadata +5 -3
data/lib/presto/client/models.rb
CHANGED
@@ -29,7 +29,9 @@ module Presto::Client
|
|
29
29
|
require 'presto/client/model_versions/0.173.rb'
|
30
30
|
require 'presto/client/model_versions/0.178.rb'
|
31
31
|
require 'presto/client/model_versions/0.205.rb'
|
32
|
+
require 'presto/client/model_versions/303.rb'
|
33
|
+
require 'presto/client/model_versions/316.rb'
|
32
34
|
|
33
|
-
Models = ModelVersions::
|
35
|
+
Models = ModelVersions::V316
|
34
36
|
|
35
37
|
end
|
data/lib/presto/client/query.rb
CHANGED
@@ -241,21 +241,24 @@ module Presto::Client
|
|
241
241
|
end
|
242
242
|
|
243
243
|
def cancel_leaf_stage
|
244
|
-
if uri = @results.
|
245
|
-
|
244
|
+
if uri = @results.partial_cancel_uri
|
245
|
+
@faraday.delete do |req|
|
246
246
|
req.url uri
|
247
247
|
end
|
248
|
-
return response.status / 100 == 2
|
249
248
|
end
|
250
|
-
return false
|
251
249
|
end
|
252
250
|
|
253
251
|
def close
|
254
252
|
return if @closed
|
255
253
|
|
256
|
-
|
257
|
-
|
258
|
-
|
254
|
+
begin
|
255
|
+
if uri = @results.next_uri
|
256
|
+
@faraday.delete do |req|
|
257
|
+
req.url uri
|
258
|
+
end
|
259
|
+
end
|
260
|
+
rescue => e
|
261
|
+
end
|
259
262
|
|
260
263
|
@closed = true
|
261
264
|
nil
|
data/modelgen/model_versions.rb
CHANGED
@@ -131,6 +131,7 @@ module Presto::Client::ModelVersions
|
|
131
131
|
when "apply" then ApplyNode
|
132
132
|
when "assignUniqueId" then AssignUniqueId
|
133
133
|
when "lateralJoin" then LateralJoinNode
|
134
|
+
when "statisticsWriterNode" then StatisticsWriterNode
|
134
135
|
end
|
135
136
|
if model_class
|
136
137
|
node = model_class.decode(hash)
|
@@ -207,6 +208,22 @@ module Presto::Client::ModelVersions
|
|
207
208
|
end
|
208
209
|
end
|
209
210
|
|
211
|
+
class << WriteStatisticsTarget =
|
212
|
+
Base.new(:type, :handle)
|
213
|
+
def decode(hash)
|
214
|
+
unless hash.is_a?(Hash)
|
215
|
+
raise TypeError, "Can't convert #{hash.class} to Hash"
|
216
|
+
end
|
217
|
+
obj = allocate
|
218
|
+
model_class = case hash["@type"]
|
219
|
+
when "WriteStatisticsHandle" then WriteStatisticsHandle
|
220
|
+
end
|
221
|
+
if model_class
|
222
|
+
model_class.decode(hash)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
210
227
|
# Inner classes
|
211
228
|
module OperatorInfo
|
212
229
|
def self.decode(hash)
|
@@ -246,6 +263,13 @@ module Presto::Client::ModelVersions
|
|
246
263
|
end
|
247
264
|
end
|
248
265
|
|
266
|
+
class ResourceGroupId < Array
|
267
|
+
def initialize(array)
|
268
|
+
super()
|
269
|
+
concat(array)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
249
273
|
##
|
250
274
|
# Those model classes are automatically generated
|
251
275
|
#
|
data/modelgen/modelgen.rb
CHANGED
@@ -13,13 +13,13 @@ erb = ERB.new(File.read(template_path))
|
|
13
13
|
|
14
14
|
source_path = source_dir
|
15
15
|
|
16
|
-
predefined_simple_classes = %w[StageId TaskId Lifespan ConnectorSession]
|
17
|
-
predefined_models = %w[DistributionSnapshot PlanNode EquiJoinClause WriterTarget OperatorInfo HashCollisionsInfo]
|
16
|
+
predefined_simple_classes = %w[StageId TaskId Lifespan ConnectorSession ResourceGroupId]
|
17
|
+
predefined_models = %w[DistributionSnapshot PlanNode EquiJoinClause WriterTarget WriteStatisticsTarget OperatorInfo HashCollisionsInfo]
|
18
18
|
|
19
|
-
assume_primitive = %w[Object Type Long Symbol QueryId PlanNodeId PlanFragmentId MemoryPoolId TransactionId URI Duration DataSize DateTime ColumnHandle ConnectorTableHandle ConnectorOutputTableHandle ConnectorIndexHandle ConnectorColumnHandle ConnectorInsertTableHandle ConnectorTableLayoutHandle Expression FunctionCall TimeZoneKey Locale TypeSignature Frame TupleDomain<ColumnHandle> SerializableNativeValue ConnectorTransactionHandle OutputBufferId ConnectorPartitioningHandle NullableValue ConnectorId HostAddress JsonNode Node]
|
20
|
-
enum_types = %w[QueryState StageState TaskState QueueState PlanDistribution OutputPartitioning Step SortOrder BufferState NullPartitioning BlockedReason ParameterKind FunctionKind PartitionFunctionHandle Scope ErrorType DistributionType PipelineExecutionStrategy JoinType]
|
19
|
+
assume_primitive = %w[Object Type Long Symbol QueryId PlanNodeId PlanFragmentId MemoryPoolId TransactionId URI Duration DataSize DateTime ColumnHandle ConnectorTableHandle ConnectorOutputTableHandle ConnectorIndexHandle ConnectorColumnHandle ConnectorInsertTableHandle ConnectorTableLayoutHandle Expression FunctionCall TimeZoneKey Locale TypeSignature Frame TupleDomain<ColumnHandle> SerializableNativeValue ConnectorTransactionHandle OutputBufferId ConnectorPartitioningHandle NullableValue ConnectorId HostAddress JsonNode Node CatalogName QualifiedObjectName]
|
20
|
+
enum_types = %w[QueryState StageState TaskState QueueState PlanDistribution OutputPartitioning Step SortOrder BufferState NullPartitioning BlockedReason ParameterKind FunctionKind PartitionFunctionHandle Scope ErrorType DistributionType PipelineExecutionStrategy JoinType ExchangeNode.Type ColumnStatisticType TableStatisticType StageExecutionStrategy SemanticErrorCode]
|
21
21
|
|
22
|
-
root_models = %w[QueryResults QueryInfo] + %w[
|
22
|
+
root_models = %w[QueryResults QueryInfo BasicQueryInfo] + %w[
|
23
23
|
OutputNode
|
24
24
|
ProjectNode
|
25
25
|
TableScanNode
|
@@ -42,7 +42,6 @@ IndexJoinNode
|
|
42
42
|
IndexSourceNode
|
43
43
|
TableWriterNode
|
44
44
|
DeleteNode
|
45
|
-
MetadataDeleteNode
|
46
45
|
TableFinishNode
|
47
46
|
UnnestNode
|
48
47
|
ExchangeNode
|
@@ -54,6 +53,7 @@ ExplainAnalyzeNode
|
|
54
53
|
ApplyNode
|
55
54
|
AssignUniqueId
|
56
55
|
LateralJoinNode
|
56
|
+
StatisticsWriterNode
|
57
57
|
] + %w[
|
58
58
|
ExchangeClientStatus
|
59
59
|
LocalExchangeBufferInfo
|
@@ -62,7 +62,8 @@ SplitOperatorInfo
|
|
62
62
|
PartitionedOutputInfo
|
63
63
|
JoinOperatorInfo
|
64
64
|
WindowInfo
|
65
|
-
TableWriterInfo
|
65
|
+
TableWriterInfo
|
66
|
+
]
|
66
67
|
|
67
68
|
name_mapping = Hash[*%w[
|
68
69
|
StatementStats StageStats ClientStageStats
|
@@ -71,13 +72,14 @@ QueryResults Column ClientColumn
|
|
71
72
|
].each_slice(3).map { |x, y, z| [[x,y], z] }.flatten(1)]
|
72
73
|
|
73
74
|
path_mapping = Hash[*%w[
|
74
|
-
ClientColumn presto-client/src/main/java/
|
75
|
-
ClientStageStats presto-client/src/main/java/
|
76
|
-
Column presto-main/src/main/java/
|
77
|
-
QueryStats presto-main/src/main/java/
|
78
|
-
StageStats presto-main/src/main/java/
|
79
|
-
PartitionedOutputInfo presto-main/src/main/java/
|
80
|
-
TableWriterInfo presto-main/src/main/java/
|
75
|
+
ClientColumn presto-client/src/main/java/io/prestosql/client/Column.java
|
76
|
+
ClientStageStats presto-client/src/main/java/io/prestosql/client/StageStats.java
|
77
|
+
Column presto-main/src/main/java/io/prestosql/execution/Column.java
|
78
|
+
QueryStats presto-main/src/main/java/io/prestosql/execution/QueryStats.java
|
79
|
+
StageStats presto-main/src/main/java/io/prestosql/execution/StageStats.java
|
80
|
+
PartitionedOutputInfo presto-main/src/main/java/io/prestosql/operator/PartitionedOutputOperator.java
|
81
|
+
TableWriterInfo presto-main/src/main/java/io/prestosql/operator/TableWriterOperator.java
|
82
|
+
TableInfo presto-main/src/main/java/io/prestosql/execution/TableInfo.java
|
81
83
|
].map.with_index { |v,i| i % 2 == 0 ? v : (source_path + "/" + v) }]
|
82
84
|
|
83
85
|
# model => [ [key,nullable,type], ... ]
|
data/modelgen/presto_models.rb
CHANGED
@@ -3,13 +3,13 @@ module PrestoModels
|
|
3
3
|
require 'find'
|
4
4
|
require 'stringio'
|
5
5
|
|
6
|
-
PRIMITIVE_TYPES = %w[String boolean long int short byte double float Integer]
|
6
|
+
PRIMITIVE_TYPES = %w[String boolean long int short byte double float Integer Double Boolean]
|
7
7
|
ARRAY_PRIMITIVE_TYPES = PRIMITIVE_TYPES.map { |t| "#{t}[]" }
|
8
8
|
|
9
9
|
class Model < Struct.new(:name, :fields)
|
10
10
|
end
|
11
11
|
|
12
|
-
class Field < Struct.new(:key, :nullable, :array, :map, :type, :base_type, :map_value_base_type)
|
12
|
+
class Field < Struct.new(:key, :nullable, :array, :map, :type, :base_type, :map_value_base_type, :base_type_alias)
|
13
13
|
alias_method :nullable?, :nullable
|
14
14
|
alias_method :array?, :array
|
15
15
|
alias_method :map?, :map
|
@@ -47,10 +47,12 @@ module PrestoModels
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
PROPERTY_PATTERN = /@JsonProperty\(\"(\w+)\"\)\s+(@Nullable\s+)?([\w\<\>\[\]\,\s]+)\s+\w+/
|
50
|
+
PROPERTY_PATTERN = /@JsonProperty\(\"(\w+)\"\)\s+(@Nullable\s+)?([\w\<\>\[\]\,\s\.]+)\s+\w+/
|
51
51
|
CREATOR_PATTERN = /@JsonCreator[\s]+public[\s]+(static\s+)?(\w+)[\w\s]*\((?:\s*#{PROPERTY_PATTERN}\s*,?)+\)/
|
52
|
+
GENERIC_PATTERN = /(\w+)\<(\w+)\>/
|
52
53
|
|
53
|
-
def analyze_fields(model_name, creator_block)
|
54
|
+
def analyze_fields(model_name, creator_block, generic: nil)
|
55
|
+
model_name = "#{model_name}_#{generic}" if generic
|
54
56
|
extra = @extra_fields[model_name] || []
|
55
57
|
fields = creator_block.scan(PROPERTY_PATTERN).concat(extra).map do |key,nullable,type|
|
56
58
|
map = false
|
@@ -63,7 +65,7 @@ module PrestoModels
|
|
63
65
|
base_type = m[1]
|
64
66
|
map_value_base_type = m[2]
|
65
67
|
map = true
|
66
|
-
elsif m = /Optional<([\w\[\]]+)>/.match(type)
|
68
|
+
elsif m = /Optional<([\w\[\]\<\>]+)>/.match(type)
|
67
69
|
base_type = m[1]
|
68
70
|
nullable = true
|
69
71
|
elsif m = /OptionalInt/.match(type)
|
@@ -72,6 +74,9 @@ module PrestoModels
|
|
72
74
|
elsif m = /OptionalLong/.match(type)
|
73
75
|
base_type = 'Long'
|
74
76
|
nullable = true
|
77
|
+
elsif m = /OptionalDouble/.match(type)
|
78
|
+
base_type = 'Double'
|
79
|
+
nullable = true
|
75
80
|
elsif type =~ /\w+/
|
76
81
|
base_type = type
|
77
82
|
else
|
@@ -79,7 +84,16 @@ module PrestoModels
|
|
79
84
|
end
|
80
85
|
base_type = @name_mapping[[model_name, base_type]] || base_type
|
81
86
|
map_value_base_type = @name_mapping[[model_name, map_value_base_type]] || map_value_base_type
|
82
|
-
|
87
|
+
|
88
|
+
if generic
|
89
|
+
base_type = generic if base_type == 'T'
|
90
|
+
map_value_base_type = generic if map_value_base_type == 'T'
|
91
|
+
end
|
92
|
+
if m = GENERIC_PATTERN.match(base_type)
|
93
|
+
base_type_alias = "#{m[1]}_#{m[2]}"
|
94
|
+
end
|
95
|
+
|
96
|
+
Field.new(key, !!nullable, array, map, type, base_type, map_value_base_type, base_type_alias)
|
83
97
|
end
|
84
98
|
|
85
99
|
@models[model_name] = Model.new(model_name, fields)
|
@@ -92,9 +106,15 @@ module PrestoModels
|
|
92
106
|
return fields
|
93
107
|
end
|
94
108
|
|
95
|
-
def analyze_model(model_name, parent_model
|
109
|
+
def analyze_model(model_name, parent_model= nil, generic: nil)
|
96
110
|
return if @models[model_name] || @ignore_types.include?(model_name)
|
97
111
|
|
112
|
+
if m = GENERIC_PATTERN.match(model_name)
|
113
|
+
analyze_model(m[1], generic: m[2])
|
114
|
+
analyze_model(m[2])
|
115
|
+
return
|
116
|
+
end
|
117
|
+
|
98
118
|
path = find_class_file(model_name, parent_model)
|
99
119
|
java = File.read(path)
|
100
120
|
|
@@ -114,7 +134,7 @@ module PrestoModels
|
|
114
134
|
fields = analyze_fields(inner_model_name, m[0])
|
115
135
|
end
|
116
136
|
|
117
|
-
fields = analyze_fields(model_name, body)
|
137
|
+
fields = analyze_fields(model_name, body, generic: generic)
|
118
138
|
|
119
139
|
rescue => e
|
120
140
|
puts "Skipping model #{parent_model}/#{model_name}: #{e}"
|
@@ -214,7 +234,7 @@ module PrestoModels
|
|
214
234
|
elem_expr = convert_expression(field.base_type, field.base_type, "h")
|
215
235
|
expr << "hash[\"#{field.key}\"].map {|h| #{elem_expr} }"
|
216
236
|
else
|
217
|
-
expr << convert_expression(field.type, field.base_type, "hash[\"#{field.key}\"]")
|
237
|
+
expr << convert_expression(field.type, field.base_type_alias || field.base_type, "hash[\"#{field.key}\"]")
|
218
238
|
end
|
219
239
|
end
|
220
240
|
|
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
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -137,6 +137,8 @@ files:
|
|
137
137
|
- lib/presto/client/model_versions/0.173.rb
|
138
138
|
- lib/presto/client/model_versions/0.178.rb
|
139
139
|
- lib/presto/client/model_versions/0.205.rb
|
140
|
+
- lib/presto/client/model_versions/303.rb
|
141
|
+
- lib/presto/client/model_versions/316.rb
|
140
142
|
- lib/presto/client/models.rb
|
141
143
|
- lib/presto/client/query.rb
|
142
144
|
- lib/presto/client/statement_client.rb
|
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
version: '0'
|
171
173
|
requirements: []
|
172
174
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.5.1
|
174
176
|
signing_key:
|
175
177
|
specification_version: 4
|
176
178
|
summary: Presto client library
|