Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ GeaFlow support the following date function:
* [lastday](#lastday)
* [day_of_month](#day_of_month)
* [week_of_year](#week_of_year)
* [quarter](#quarter)
* [day_of_year](#day_of_year)
* [date_add](#date_add)
* [date_sub](#date_sub)
* [date_diff](#date_diff)
Expand Down Expand Up @@ -205,7 +207,34 @@ Returns the week of the year of the given date. The default format is "yyyy-MM-d
```sql
week_of_year('1987-06-05 00:11:22') = 23
```
## quarter
**Syntax**

```sql
int quarter(string dateString)
```

**Description**
Returns the quarter of the year of the given date (1-4). The default format is "yyyy-MM-dd" or "yyyy-MM-dd HH:mm:ss". Returns null if the input is null.

**Example**
```sql
quarter('1987-06-05 00:11:22') = 2
```
## day_of_year

**Syntax**

```sql
int day_of_year(string dateString)
```
**Description**
Returns the day of the year of the given date (1-366). The default format is "yyyy-MM-dd" or "yyyy-MM-dd HH:mm:ss". Returns null if the input is null.

**Example**
```sql
day_of_year('1987-06-05 00:11:22') = 156
```

## date_add
**Syntax**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
import org.apache.geaflow.dsl.udf.table.date.UnixTimeStampMillis;
import org.apache.geaflow.dsl.udf.table.date.WeekDay;
import org.apache.geaflow.dsl.udf.table.date.WeekOfYear;
import org.apache.geaflow.dsl.udf.table.date.Quarter;
import org.apache.geaflow.dsl.udf.table.date.DayOfYear;
import org.apache.geaflow.dsl.udf.table.date.Year;
import org.apache.geaflow.dsl.udf.table.math.Cbrt;
import org.apache.geaflow.dsl.udf.table.math.E;
Expand Down Expand Up @@ -132,6 +134,7 @@
import org.apache.geaflow.dsl.udf.table.string.UrlEncode;
import org.apache.geaflow.dsl.util.FunctionUtil;


/**
* SQL build-in {@link SqlFunction}s.
*/
Expand Down Expand Up @@ -167,6 +170,8 @@ public class BuildInSqlFunctionTable extends ListSqlOperatorTable {
.add(GeaFlowFunction.of(UnixTimeStampMillis.class))
.add(GeaFlowFunction.of(WeekDay.class))
.add(GeaFlowFunction.of(WeekOfYear.class))
.add(GeaFlowFunction.of(Quarter.class))
.add(GeaFlowFunction.of(DayOfYear.class))
.add(GeaFlowFunction.of(Year.class))

// udf.table.array
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import org.apache.geaflow.dsl.udf.table.date.UnixTimeStampMillis;
import org.apache.geaflow.dsl.udf.table.date.WeekDay;
import org.apache.geaflow.dsl.udf.table.date.WeekOfYear;
import org.apache.geaflow.dsl.udf.table.date.Quarter;
import org.apache.geaflow.dsl.udf.table.date.DayOfYear;
import org.apache.geaflow.dsl.udf.table.date.Year;
import org.testng.annotations.Test;

Expand Down