Skip to content

Commit aac63c4

Browse files
committed
to fix script with date parse function
1 parent d18742b commit aac63c4

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

bridge/src/test/scala/app/softnetwork/elastic/sql/SQLQuerySpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,11 +1373,6 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
13731373
| }
13741374
| },
13751375
| "aggs": {
1376-
| "ct": {
1377-
| "value_count": {
1378-
| "field": "identifier2"
1379-
| }
1380-
| },
13811376
| "lastSeen": {
13821377
| "max": {
13831378
| "field": "createdAt",
@@ -1386,6 +1381,11 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
13861381
| "source": "def param1 = (doc['createdAt'].size() == 0 ? null : doc['createdAt'].value); (param1 == null) ? null : ZonedDateTime.parse(param1, DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss.SSS XXX\")).truncatedTo(ChronoUnit.MINUTES).get(ChronoField.YEAR)"
13871382
| }
13881383
| }
1384+
| },
1385+
| "ct": {
1386+
| "value_count": {
1387+
| "field": "identifier2"
1388+
| }
13891389
| }
13901390
| }
13911391
| }

es6/bridge/src/test/scala/app/softnetwork/elastic/sql/SQLQuerySpec.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,11 +1373,6 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
13731373
| }
13741374
| },
13751375
| "aggs": {
1376-
| "ct": {
1377-
| "value_count": {
1378-
| "field": "identifier2"
1379-
| }
1380-
| },
13811376
| "lastSeen": {
13821377
| "max": {
13831378
| "field": "createdAt",
@@ -1386,6 +1381,11 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
13861381
| "source": "def param1 = (doc['createdAt'].size() == 0 ? null : doc['createdAt'].value); (param1 == null) ? null : ZonedDateTime.parse(param1, DateTimeFormatter.ofPattern(\"yyyy-MM-dd HH:mm:ss.SSS XXX\")).truncatedTo(ChronoUnit.MINUTES).get(ChronoField.YEAR)"
13871382
| }
13881383
| }
1384+
| },
1385+
| "ct": {
1386+
| "value_count": {
1387+
| "field": "identifier2"
1388+
| }
13891389
| }
13901390
| }
13911391
| }

sql/src/main/scala/app/softnetwork/elastic/sql/function/time/package.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ package object time {
499499

500500
case class DateParse(identifier: Identifier, format: String)
501501
extends DateFunction
502+
with DateMathScript
502503
with TransformFunction[SQLVarchar, SQLDate]
503504
with FunctionWithIdentifier
504-
with FunctionWithDateTimeFormat
505-
with DateMathScript {
505+
with FunctionWithDateTimeFormat {
506506
override def fun: Option[PainlessScript] = None
507507

508508
override def args: List[PainlessScript] = List(identifier)
@@ -548,6 +548,8 @@ package object time {
548548
}
549549

550550
override def formatScript: Option[String] = Some(format)
551+
552+
override def shouldBeScripted: Boolean = true // FIXME
551553
}
552554

553555
case object DateFormat extends Expr("DATE_FORMAT") with TokenRegex with PainlessScript {

0 commit comments

Comments
 (0)