Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichard committed Apr 4, 2023
1 parent 9bdcd87 commit efdafc1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1148,25 +1148,25 @@ object Expression {
sealed trait IntervalField extends LeafExpression {
override def toString(): String = getClass.getSimpleName
}
case class Year(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Quarter(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Month(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Week(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Day(nodeLocation: Option[NodeLocation]) extends IntervalField
case class DayOfWeek(nodeLocation: Option[NodeLocation]) extends IntervalField {
case class Year(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Quarter(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Month(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Week(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Day(nodeLocation: Option[NodeLocation]) extends IntervalField
case class DayOfWeek(nodeLocation: Option[NodeLocation]) extends IntervalField {
override def toString(): String = "day_of_week"
}
case class DayOfYear(nodeLocation: Option[NodeLocation]) extends IntervalField {
case class DayOfYear(nodeLocation: Option[NodeLocation]) extends IntervalField {
override def toString(): String = "day_of_year"
}
case class YearOfWeek(nodeLocation: Option[NodeLocation]) extends IntervalField {
case class YearOfWeek(nodeLocation: Option[NodeLocation]) extends IntervalField {
override def toString(): String = "year_of_week"
}
case class Hour(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Minute(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Second(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Hour(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Minute(nodeLocation: Option[NodeLocation]) extends IntervalField
case class Second(nodeLocation: Option[NodeLocation]) extends IntervalField

case class TimezoneHour(nodeLocation: Option[NodeLocation]) extends IntervalField {
case class TimezoneHour(nodeLocation: Option[NodeLocation]) extends IntervalField {
override def toString(): String = "timezone_hour"
}
case class TimezoneMinute(nodeLocation: Option[NodeLocation]) extends IntervalField {
Expand Down Expand Up @@ -1258,8 +1258,8 @@ object Expression {

case class Extract(interval: IntervalField, expr: Expression, nodeLocation: Option[NodeLocation]) extends Expression {
override def children: Seq[Expression] = Seq(expr)
override def sqlExpr: String = s"EXTRACT(${interval.sqlExpr} FROM ${expr.sqlExpr})"
override def toString = s"Extract(interval:${interval}, ${expr})"
override def sqlExpr: String = s"EXTRACT(${interval.sqlExpr} FROM ${expr.sqlExpr})"
override def toString = s"Extract(interval:${interval}, ${expr})"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -810,22 +810,22 @@ class SQLInterpreter(withNodeLocation: Boolean = true) extends SqlBaseBaseVisito

override def visitExtract(ctx: SqlBaseParser.ExtractContext): Expression = {
val intervalLocation = getLocation(ctx.identifier())
val expr = expression(ctx.valueExpression())
val expr = expression(ctx.valueExpression())
ctx.identifier().getText().toUpperCase() match {
case "YEAR" => Extract(Year(intervalLocation), expr, getLocation(ctx))
case "QUARTER" => Extract(Quarter(intervalLocation), expr, getLocation(ctx))
case "MONTH" => Extract(Month(intervalLocation), expr, getLocation(ctx))
case "WEEK" => Extract(Week(intervalLocation), expr, getLocation(ctx))
case "YEAR" => Extract(Year(intervalLocation), expr, getLocation(ctx))
case "QUARTER" => Extract(Quarter(intervalLocation), expr, getLocation(ctx))
case "MONTH" => Extract(Month(intervalLocation), expr, getLocation(ctx))
case "WEEK" => Extract(Week(intervalLocation), expr, getLocation(ctx))
case "DAY" | "DAY_OF_MONTH" => Extract(Day(intervalLocation), expr, getLocation(ctx))
case "DAY_OF_WEEK" | "DOW" => Extract(DayOfWeek(intervalLocation), expr, getLocation(ctx))
case "DAY_OF_YEAR" | "DOY" => Extract(DayOfYear(intervalLocation), expr, getLocation(ctx))
case "DAY_OF_WEEK" | "DOW" => Extract(DayOfWeek(intervalLocation), expr, getLocation(ctx))
case "DAY_OF_YEAR" | "DOY" => Extract(DayOfYear(intervalLocation), expr, getLocation(ctx))
case "YEAR_OF_WEEK" | "YOW" => Extract(YearOfWeek(intervalLocation), expr, getLocation(ctx))
case "HOUR" => Extract(Hour(intervalLocation), expr, getLocation(ctx))
case "MINUTE" => Extract(Minute(intervalLocation), expr, getLocation(ctx))
case "SECOND" => Extract(Second(intervalLocation), expr, getLocation(ctx))
case "TIMEZONE_HOUR" => Extract(TimezoneHour(intervalLocation), expr, getLocation(ctx))
case "TIMEZONE_MINUTE" => Extract(TimezoneMinute(intervalLocation), expr, getLocation(ctx))
case _ => throw unknown(ctx)
case "HOUR" => Extract(Hour(intervalLocation), expr, getLocation(ctx))
case "MINUTE" => Extract(Minute(intervalLocation), expr, getLocation(ctx))
case "SECOND" => Extract(Second(intervalLocation), expr, getLocation(ctx))
case "TIMEZONE_HOUR" => Extract(TimezoneHour(intervalLocation), expr, getLocation(ctx))
case "TIMEZONE_MINUTE" => Extract(TimezoneMinute(intervalLocation), expr, getLocation(ctx))
case _ => throw unknown(ctx)
}
}

Expand Down

0 comments on commit efdafc1

Please sign in to comment.