Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function Support for Elasticsearch-SQL #269

Merged
merged 124 commits into from Aug 25, 2016

Conversation

allwefantasy
Copy link
Member

@allwefantasy allwefantasy commented Aug 25, 2016

features

All features following require ES with groovy script enabled.

  • Distinct precision_threshold depends on ES or you can specify by second parameters.
    When you have lot of shards, 40000 consume too much memory.
  • select,groupBy now support functions and field alias
  • nested function is also available,eg. split(substring('newtype',0,3),'c')[0]
  • Binary operation support now, eg. floor(substring(newtype,0,14)/100)/5)*5

pom.xml changes

Profile local and online are added. So we can choose profile we want in IDE eg. Intel Idea.
local make you run Application without dependency problem since the scope of some dependences is setted to provied.

MainTestSuite changes

Cause the unit test depend on ES instance, it make confuse sometimes that we just can not connect local ES instance just because the cluster_name is not consistent。

Settings settings = Settings.builder().put("client.transport.ignore_cluster_name",true).build();

functions support

  • floor
  • split
  • trim
  • log
  • log10
  • substring
  • round
  • sqrt
  • concat_ws
  • *
  • /
  • %

Unit Test

org.nlpcn.es4sql.SQLFunctionsTest

Example

check Example file:

org.nlpcn.es4sql.Test

SQLs:

SELECT newtype as nt  from  twitter2 

SELECT sum(num) as num2,newtype as nt  
from  twitter2 
group by nt  order by num2 

SELECT sum(num_d) as num2,split(newtype,',') as nt  
from  twitter2 
group by nt  
order by num2

SELECT sum(num_d) as num2,floor(num) as nt  
from  twitter2 
group by floor(num),newtype  
order by num2

SELECT split('newtype','b')[1] as nt,sum(num_d) as num2   
from  twitter2 
group by nt

SELECT split(substring('newtype',0,3),'c')[0] as nt,num_d   
from  twitter2 
group by nt

SELECT trim(newtype) as nt 
from  twitter2


SELECT floor(floor(substring(time,0,14)/100)/5)*5 as nt,
count(distinct(mid)) as cvalue 
FROM twitter2  
where ty='buffer' and day='20160815' and domain='baidu.com' 
group by nt 
order by cvalue 

eliranmoyal and others added 30 commits November 6, 2015 10:38
… not in QueryMaker. Applied the same fix to QueryMaker.

Reverted the change to SqlParser to be what it is supposed to be.
Added another test to the double not test so both scenarios are tested now
Fixed double nots in 2.0.0 version.
Conflicts:
	src/main/java/org/nlpcn/es4sql/query/maker/Maker.java
Conflicts:
	src/main/java/org/nlpcn/es4sql/domain/Condition.java
	src/main/java/org/nlpcn/es4sql/query/maker/Maker.java
Conflicts:
	src/main/java/org/nlpcn/es4sql/domain/Condition.java
Conflicts:
	pom.xml
	src/main/java/org/nlpcn/es4sql/query/maker/AggMaker.java
Conflicts:
	src/test/java/org/nlpcn/es4sql/QueryTest.java
@allwefantasy allwefantasy merged commit e33d9eb into NLPchina:master Aug 25, 2016
@shi-yuan
Copy link
Member

shi-yuan commented Aug 25, 2016

@allwefantasy That's cool!
Could you please add features.md to wiki ?

@allwefantasy
Copy link
Member Author

@shi-yuan Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants