sparkql 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODFlYzJkZDViM2E4OWI2YmRmZDc0MTIyYTVmZDFlNzdhMzlkYzJkMg==
4
+ ZDJhMGNlYzU2MzNhMzQyZTZjMjE1YWQzYzQxZmZhNmQyZTkwNzEwOQ==
5
5
  data.tar.gz: !binary |-
6
- YmYzYWIyZDJiZTRkZTYyZjg4NzQyYzYxZGI4OTQ1OWQzNDIzN2M4ZQ==
6
+ MDc2M2E2NDk3MjQwNTI4NWExZWRhMTE1OGFhNzYwYTg2YTViMDhkNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGRjNTRhZDU5NjQ1NmFkOGUzMjQ4M2JhOTNiY2Q1NTdiOWM2ODQ0NGVmYzY0
10
- Yjk0OTQyZWEwY2I3ZGUyMTA3YWI4YmJkOTFjOGUzMDMyN2QwNWYzNjg1MTRl
11
- OTNiOTkyNDY2OTYxYWI0ZDQ2YjUyMjZkYWRkZDgzNDI4NGViYTU=
9
+ YmI0ZTZjNmFjYjNjZThiMTVlMWJhNTkxN2EwNDI3YmRmZTg3ZmYyNDJiYTdm
10
+ OWFhMTQ5NDhlY2EwNGRkMzE3MGU0NTlhZDQwZWNmMGUzMThkM2JiZjVmOTAy
11
+ YmE0ZmE3OWFmY2RiZWEyYjJlNjE4MGVmN2NjMTc2OWQ0ODJlYTY=
12
12
  data.tar.gz: !binary |-
13
- YTFjOTA1YjUyMzc2MWQzMTE5YWUzMDY5MjVjNGFhMDg5NzVmNTBjZDNkZDlm
14
- YWJkMDBjNzYwNmI5MTcwY2QzZGYyNWEyODNiNDAzNTdiNTA3YjQ1NzQ4MTI1
15
- YjIzYTdmZDQwNjA0OTFiNzhhNWJjODJjMTk1YzZhMjI5N2ZhNDk=
13
+ OGQ5OGI2YzdlNmUxYTVkOTJhNjk3NGEwM2ExODAwZGQ4MDA3M2M5YmVjNDcx
14
+ M2RlNmU3YjU5Zjk5NTgyNjljOTI2ZjZmODRmZjljZTExOTIwNzM3ZTdiMGJk
15
+ ZDc2NTI3NWUzMTlhOTg5NzM1NWYxOTg5ZDJkMTY1MTc4YmRhNDY=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ v1.1.2, 2016-11-08 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.1...v1.1.2))
2
+ -------------------
3
+ * [IMPROVEMENT] New functions: year(), month(), day(), hour(), minute(), second(), and
4
+ fractionalseconds().
5
+
1
6
  v1.1.1, 2016-09-09 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.0...v1.1.1))
2
7
  -------------------
3
8
  * [BUGFIX] Fix `Not` handling in the new Evaluation class
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -55,15 +55,50 @@ class Sparkql::FunctionResolver
55
55
  :return_type => :datetime
56
56
  },
57
57
  :date => {
58
- :args => [[:field,:datetime]],
58
+ :args => [[:field,:datetime,:date]],
59
59
  :resolve_for_type => true,
60
60
  :return_type => :date
61
61
  },
62
62
  :time => {
63
- :args => [[:field,:datetime]],
63
+ :args => [[:field,:datetime,:date]],
64
64
  :resolve_for_type => true,
65
65
  :return_type => :time
66
66
  },
67
+ :year => {
68
+ :args => [[:field,:datetime,:date]],
69
+ :resolve_for_type => true,
70
+ :return_type => :integer
71
+ },
72
+ :month => {
73
+ :args => [[:field,:datetime,:date]],
74
+ :resolve_for_type => true,
75
+ :return_type => :integer
76
+ },
77
+ :day => {
78
+ :args => [[:field,:datetime,:date]],
79
+ :resolve_for_type => true,
80
+ :return_type => :integer
81
+ },
82
+ :hour => {
83
+ :args => [[:field,:datetime,:date]],
84
+ :resolve_for_type => true,
85
+ :return_type => :integer
86
+ },
87
+ :minute => {
88
+ :args => [[:field,:datetime,:date]],
89
+ :resolve_for_type => true,
90
+ :return_type => :integer
91
+ },
92
+ :second => {
93
+ :args => [[:field,:datetime,:date]],
94
+ :resolve_for_type => true,
95
+ :return_type => :integer
96
+ },
97
+ :fractionalseconds => {
98
+ :args => [[:field,:datetime,:date]],
99
+ :resolve_for_type => true,
100
+ :return_type => :decimal
101
+ },
67
102
  :range => {
68
103
  :args => [:character, :character],
69
104
  :return_type => :character
@@ -218,6 +253,62 @@ class Sparkql::FunctionResolver
218
253
  }
219
254
  end
220
255
 
256
+ def year_field(arg)
257
+ {
258
+ :type => :function,
259
+ :value => "year",
260
+ :args => [arg]
261
+ }
262
+ end
263
+
264
+ def month_field(arg)
265
+ {
266
+ :type => :function,
267
+ :value => "month",
268
+ :args => [arg]
269
+ }
270
+ end
271
+
272
+ def day_field(arg)
273
+ {
274
+ :type => :function,
275
+ :value => "day",
276
+ :args => [arg]
277
+ }
278
+ end
279
+
280
+ def hour_field(arg)
281
+ {
282
+ :type => :function,
283
+ :value => "hour",
284
+ :args => [arg]
285
+ }
286
+ end
287
+
288
+ def minute_field(arg)
289
+ {
290
+ :type => :function,
291
+ :value => "minute",
292
+ :args => [arg]
293
+ }
294
+ end
295
+
296
+ def second_field(arg)
297
+ {
298
+ :type => :function,
299
+ :value => "second",
300
+ :args => [arg]
301
+ }
302
+ end
303
+
304
+ def fractionalseconds_field(arg)
305
+ {
306
+ :type => :function,
307
+ :value => "fractionalseconds",
308
+ :args => [arg]
309
+ }
310
+ end
311
+
221
312
  def date_datetime(dt)
222
313
  {
223
314
  :type => :date,
@@ -63,7 +63,39 @@ class FunctionResolverTest < Test::Unit::TestCase
63
63
  assert_equal '2010-01-06', value[:value], "negative values should go back in time"
64
64
  end
65
65
 
66
-
66
+ test "year(), month(), and day()" do
67
+ ['year', 'month', 'day'].each do |function|
68
+ f = FunctionResolver.new(function, [{:type => :field, :value => "OriginalEntryTimestamp"}])
69
+ f.validate
70
+ assert !f.errors?, "Errors #{f.errors.inspect}"
71
+ value = f.call
72
+ assert_equal :function, value[:type]
73
+ assert_equal function, value[:value]
74
+ assert_equal "OriginalEntryTimestamp", value[:args].first
75
+ end
76
+ end
77
+
78
+ test "hour(), minute(), and second()" do
79
+ ['year', 'month', 'day'].each do |function|
80
+ f = FunctionResolver.new(function, [{:type => :field, :value => "OriginalEntryTimestamp"}])
81
+ f.validate
82
+ assert !f.errors?, "Errors #{f.errors.inspect}"
83
+ value = f.call
84
+ assert_equal :function, value[:type]
85
+ assert_equal function, value[:value]
86
+ assert_equal "OriginalEntryTimestamp", value[:args].first
87
+ end
88
+ end
89
+
90
+ test "fractionalseconds()" do
91
+ f = FunctionResolver.new('fractionalseconds', [{:type => :field, :value => "OriginalEntryTimestamp"}])
92
+ f.validate
93
+ assert !f.errors?, "Errors #{f.errors.inspect}"
94
+ value = f.call
95
+ assert_equal :function, value[:type]
96
+ assert_equal 'fractionalseconds', value[:value]
97
+ assert_equal "OriginalEntryTimestamp", value[:args].first
98
+ end
67
99
 
68
100
  # Polygon searches
69
101
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparkql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade McEwen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: georuby