Skip to content

Commit 1afe18a

Browse files
committed
Decimal literal should convert to double in pushdown
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 1753314 commit 1afe18a

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

  • integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues
  • opensearch/src/main/java/org/opensearch/sql/opensearch/request
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
setup:
2+
- do:
3+
query.settings:
4+
body:
5+
transient:
6+
plugins.calcite.enabled : true
7+
plugins.calcite.fallback.allowed : false
8+
9+
---
10+
teardown:
11+
- do:
12+
query.settings:
13+
body:
14+
transient:
15+
plugins.calcite.enabled : false
16+
plugins.calcite.fallback.allowed : true
17+
18+
---
19+
"Decimal literal should convert to double in pushdown":
20+
- skip:
21+
features:
22+
- headers
23+
- do:
24+
bulk:
25+
index: test
26+
refresh: true
27+
body:
28+
- '{"index": {}}'
29+
- '{"balance": 1000.0}'
30+
- do:
31+
headers:
32+
Content-Type: 'application/json'
33+
ppl:
34+
body:
35+
query: 'source=test | where balance >= 1000.0 | stats avg(balance)'
36+
- match: {"total": 1}
37+
- match: {"schema": [{"name": "avg(balance)", "type": "double"}]}
38+
- match: {"datarows": [[1000.0]]}

opensearch/src/main/java/org/opensearch/sql/opensearch/request/PredicateAnalyzer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ Object value() {
10571057
return sargValue();
10581058
} else if (isIntegral()) {
10591059
return longValue();
1060-
} else if (isFloatingPoint()) {
1060+
} else if (isFractional()) {
10611061
return doubleValue();
10621062
} else if (isBoolean()) {
10631063
return booleanValue();
@@ -1072,8 +1072,8 @@ boolean isIntegral() {
10721072
return SqlTypeName.INT_TYPES.contains(literal.getType().getSqlTypeName());
10731073
}
10741074

1075-
boolean isFloatingPoint() {
1076-
return SqlTypeName.APPROX_TYPES.contains(literal.getType().getSqlTypeName());
1075+
boolean isFractional() {
1076+
return SqlTypeName.FRACTIONAL_TYPES.contains(literal.getType().getSqlTypeName());
10771077
}
10781078

10791079
boolean isBoolean() {

0 commit comments

Comments
 (0)