sparkql 1.1.11 → 1.1.12

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTkxNTEwOGJhMzYwNDEyMmU1OTBkNDkyZGJjNDNlY2NkMjY1MzI4ZA==
4
+ ZmEwYzgyNzFiMjg1MWE0ODQ5YjcyOGMwZDA0MDY2ZmE3MmQ2ZGZjMA==
5
5
  data.tar.gz: !binary |-
6
- YWY0MzliNGIwNmQ5ODgwZDdhY2ZhZWFjMWIwMGU3NDg0YjNlMmQzOA==
6
+ Y2M4N2YyNmEyMjFiNDNiMzQ3ODg1YzUxYjljYzQwM2Y0MDdhOTJiNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTQ4NzkxMGJiZmI4ZTY3NWYxYmM0NmMzOThhNzY4NGIxNGMxZWU3MTA1NDMw
10
- OTFmNjFkNTYwODIwMGEwZDdkYjE5NGM3ZjA0NjM5ZDE2ZDlhN2ViYWFjMGRk
11
- NGM5YjcwNWZhMzczNGM1MjM1MmJkNTRkNjBhZWJlMjBlYWExODU=
9
+ YTg2NDIxZDc0NGM3ZGE1YzZjZWQ2N2I5M2QwODg1NzcxODU4MWI2YTE2YTI5
10
+ YjAzN2E0YTMwNzI5Y2QyZmIzNmY0MjdiMmQ2ZDBkMDU5NDk2MWJhNWYxMTgw
11
+ ZDRhNDA3MzY2NmVkMjdiZDJiNGFkOTVkNmY1ZmY2OGM1ZGFjNTE=
12
12
  data.tar.gz: !binary |-
13
- OGNmOTM4Yjg1MWRmZDg1OGYzYmE2ZTI2ODYwNjNiMjdlZTY4NTIwMGM0M2M4
14
- OGFlYmJlMDljYzZlMDRiODY2MzdiNDM3OWY0Mjk1OWI5YzA0NGJhMGE4NjJm
15
- MDA1MWEzYmNmNWZhNjBmM2VhZWY3ZjkzNzAwMWNjYTk1ZjM5NzE=
13
+ NzZjOTgwZGVhYzY0NzM0NTAzYjliYmRlMjExM2M2OGM5NmMxZTQwYmFjNTQz
14
+ ZTNmY2Q1YWFmN2M4ZTkxY2Y0NjRlMGU5MzAyNDFmM2ZhODg5ZGJhZGM5ZDU5
15
+ ODk5ODhjNTU1ZjVkYTEwNGIzMmJlMjM0YmQwMWM3YzZhNjE5ODI=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v1.1.12, 2018-06-26
2
+ -------------------
3
+ * [IMPROVEMENT] New Function: indexof()
4
+
1
5
  v1.1.11, 2018-03-30
2
6
  -------------------
3
7
  * [BUGFIX] contains(), startswith(), endswith() are now case-sensitive
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.11
1
+ 1.1.12
@@ -45,6 +45,10 @@ class Sparkql::FunctionResolver
45
45
  :resolve_for_type => true,
46
46
  :return_type => :character
47
47
  },
48
+ :indexof => {
49
+ :args => [[:field, :character], :character],
50
+ :return_type => :integer
51
+ },
48
52
  :startswith => {
49
53
  :args => [:character],
50
54
  :return_type => :startswith
@@ -349,7 +353,15 @@ class Sparkql::FunctionResolver
349
353
  :value => Time.now.iso8601
350
354
  }
351
355
  end
352
-
356
+
357
+ def indexof(arg1, arg2)
358
+ {
359
+ :type => :function,
360
+ :value => "indexof",
361
+ :args => [arg1, arg2]
362
+ }
363
+ end
364
+
353
365
  def date_field(arg)
354
366
  {
355
367
  :type => :function,
@@ -32,6 +32,7 @@ module Sparkql::ParserTools
32
32
  if !function.nil?
33
33
  field_args[:field_function] = field[:value]
34
34
  field_args[:field_function_type] = function[:return_type]
35
+ field_args[:args] = field[:args]
35
36
  else
36
37
  tokenizer_error(:token => field[:value],
37
38
  :message => "Unsupported function type", :status => :fatal )
@@ -148,7 +149,7 @@ module Sparkql::ParserTools
148
149
  return nil
149
150
  else
150
151
  result = resolver.call()
151
- return result.nil? ? result : result.merge(:condition => "#{name}(#{condition_list.join(',')})")
152
+ result.nil? ? result : result.merge(:condition => "#{name}(#{condition_list.join(',')})")
152
153
  end
153
154
  end
154
155
 
@@ -174,7 +174,6 @@ class ParserTest < Test::Unit::TestCase
174
174
  end
175
175
 
176
176
  def test_function_range
177
- start = Time.now
178
177
  filter = "MapCoordinates Eq range('M01','M04')"
179
178
  @parser = Parser.new
180
179
  expressions = @parser.parse(filter)
@@ -184,6 +183,16 @@ class ParserTest < Test::Unit::TestCase
184
183
  assert_equal 'M04', expressions.first[:value][1]
185
184
  end
186
185
 
186
+ test 'indexof with field' do
187
+ filter = "indexof(City, '4131800000000') Eq 13"
188
+ @parser = Parser.new
189
+ expression = @parser.parse(filter).first
190
+ assert !@parser.errors?, "errors #{@parser.errors.inspect}"
191
+ assert_equal 'City', expression[:field]
192
+ assert_equal '13', expression[:value]
193
+ assert_equal '4131800000000', expression[:args].last
194
+ end
195
+
187
196
  test "function data preserved in expression" do
188
197
  filter = "OriginalEntryTimestamp Ge days(-7)"
189
198
  @parser = Parser.new
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.11
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wade McEwen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: georuby