Skip to content

Commit 522faa0

Browse files
committed
test extract function
1 parent 04a1fc4 commit 522faa0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
12591259
| "field": "createdAt",
12601260
| "script": {
12611261
| "lang": "painless",
1262-
| "source": "DateTimeFormatter.ofPattern('yyyy-MM-ddTHH:mm:ssZ').parse(doc['createdAt'].value, LocalDateTime::from).truncatedTo(ChronoUnit.MINUTES)"
1262+
| "source": "DateTimeFormatter.ofPattern('yyyy-MM-ddTHH:mm:ssZ').parse(doc['createdAt'].value, LocalDateTime::from).truncatedTo(ChronoUnit.MINUTES).get(ChronoUnit.YEARS)"
12631263
| }
12641264
| }
12651265
| }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ class SQLQuerySpec extends AnyFlatSpec with Matchers {
12561256
| "field": "createdAt",
12571257
| "script": {
12581258
| "lang": "painless",
1259-
| "source": "DateTimeFormatter.ofPattern('yyyy-MM-ddTHH:mm:ssZ').parse(doc['createdAt'].value, LocalDateTime::from).truncatedTo(ChronoUnit.MINUTES)"
1259+
| "source": "DateTimeFormatter.ofPattern('yyyy-MM-ddTHH:mm:ssZ').parse(doc['createdAt'].value, LocalDateTime::from).truncatedTo(ChronoUnit.MINUTES).get(ChronoUnit.YEARS)"
12601260
| }
12611261
| }
12621262
| }

sql/src/test/scala/app/softnetwork/elastic/sql/SQLParserSpec.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,21 @@ object Queries {
9898
.replaceAll("\n", " ")
9999
val parseDate =
100100
"select identifier, count(identifier2) as ct, max(parse_date('yyyy-MM-dd')(createdAt)) as lastSeen from Table where identifier2 is not null group by identifier order by count(identifier2) desc"
101-
val parseDateTime =
102-
"select identifier, count(identifier2) as ct, max(date_trunc(minute)(parse_datetime('yyyy-MM-ddTHH:mm:ssZ')(createdAt))) as lastSeen from Table where identifier2 is not null group by identifier order by count(identifier2) desc"
101+
val parseDateTime: String =
102+
"""select identifier, count(identifier2) as ct,
103+
|max(
104+
|year(
105+
|date_trunc(minute)(
106+
|parse_datetime('yyyy-MM-ddTHH:mm:ssZ')(
107+
|createdAt
108+
|)))) as lastSeen
109+
|from Table
110+
|where identifier2 is not null
111+
|group by identifier
112+
|order by count(identifier2) desc""".stripMargin
113+
.replaceAll("\n", " ")
114+
.replaceAll("\\( ", "(")
115+
.replaceAll(" \\)", ")")
103116

104117
}
105118

0 commit comments

Comments
 (0)