Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Enable Date type input in function Count() #931

Merged

Conversation

harold-wang
Copy link
Contributor

Issue #916, if available:

Description of changes:

Add three input type (DATE, DATETIME, TIMESTAMP) in Count()
Add UT (DATE, DATETIME or TIMESTAMP) input type
Add Comparison Test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Add IT
Add Comparsion Test
@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #931 (f7c3f51) into develop (64c7bd6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop     #931   +/-   ##
==========================================
  Coverage      99.86%   99.86%           
- Complexity      2265     2315   +50     
==========================================
  Files            229      230    +1     
  Lines           5235     5329   +94     
  Branches         346      346           
==========================================
+ Hits            5228     5322   +94     
  Misses             5        5           
  Partials           2        2           
Impacted Files Coverage Δ Complexity Δ
...sql/expression/aggregation/AggregatorFunction.java 100.00% <100.00%> (ø) 31.00 <2.00> (-6.00)
...opendistroforelasticsearch/sql/expression/DSL.java 100.00% <0.00%> (ø) 128.00% <0.00%> (+9.00%)
...elasticsearch/sql/analysis/ExpressionAnalyzer.java 100.00% <0.00%> (ø) 31.00% <0.00%> (+1.00%)
...ticsearch/sql/sql/parser/AstExpressionBuilder.java 100.00% <0.00%> (ø) 50.00% <0.00%> (+2.00%)
...search/sql/expression/config/ExpressionConfig.java 100.00% <0.00%> (ø) 3.00% <0.00%> (ø%)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <0.00%> (ø) 3.00% <0.00%> (ø%)
.../expression/operator/convert/TypeCastOperator.java 100.00% <0.00%> (ø) 44.00% <0.00%> (?%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64c7bd6...f7c3f51. Read the comment docs.

Copy link
Member

@chloe-zh chloe-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the changes. A suggestion: it is fine to address comments and make changes to your code in the same pull request rather than open a new one for replacement. As long as you "squash and merge" all the commits to one commit at the end when you merge your PR.

Comment on lines 97 to 102
.put(new FunctionSignature(functionName, Collections.singletonList(DATE)),
arguments -> new CountAggregator(arguments, INTEGER))
.put(new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
arguments -> new CountAggregator(arguments, INTEGER))
.put(new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
arguments -> new CountAggregator(arguments, INTEGER))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume SQL COUNT() should work with all types. If so, is it more maintainable to generate function signatures from all core types like this way:

Copy link
Contributor

@penghuo penghuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copy link
Member

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@harold-wang harold-wang merged commit c377026 into opendistro-for-elasticsearch:develop Dec 15, 2020
@harold-wang harold-wang deleted the countFix branch December 15, 2020 18:10
penghuo pushed a commit to penghuo/sql that referenced this pull request Dec 17, 2020
…rch#931)

* Enable count(Date)
Add IT
Add Comparsion Test

* Enable count(Date)
Add IT

* Add comparsion test file 916.txt

* Consolidate count function to accept all field type
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants