Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhztheplayer committed Aug 26, 2024
1 parent 264a7e9 commit a5d5ea6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ import org.apache.spark.unsafe.types.CalendarInterval
case class CustomAdd(
left: Expression,
right: Expression,
failOnError: Boolean = SQLConf.get.ansiEnabled)
extends BinaryArithmetic {
override val failOnError: Boolean = SQLConf.get.ansiEnabled)
extends BinaryArithmetic
with CustomAdd.Compatibility {

def this(left: Expression, right: Expression) = this(left, right, SQLConf.get.ansiEnabled)

Expand Down Expand Up @@ -69,6 +70,14 @@ case class CustomAdd(
newLeft: Expression,
newRight: Expression
): CustomAdd = copy(left = newLeft, right = newRight)

override protected val evalMode: EvalMode.Value = EvalMode.LEGACY
}

object CustomAdd {
trait Compatibility {
protected val evalMode: EvalMode.Value
}
}

class GlutenClickhouseCustomerExpressionTransformerSuite
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.catalyst.expressions

import org.apache.spark.sql.internal.SQLConf

/** For compatibility with Spark version <= 3.3. The class was added in vanilla Spark since 3.4. */
object EvalMode extends Enumeration {
val LEGACY, ANSI, TRY = Value

def fromSQLConf(conf: SQLConf): Value = if (conf.ansiEnabled) {
ANSI
} else {
LEGACY
}

def fromBoolean(ansiEnabled: Boolean): Value = if (ansiEnabled) {
ANSI
} else {
LEGACY
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.sql.catalyst.expressions

import org.apache.spark.sql.internal.SQLConf

/** For compatibility with Spark version <= 3.3. The class was added in vanilla Spark since 3.4. */
object EvalMode extends Enumeration {
val LEGACY, ANSI, TRY = Value

def fromSQLConf(conf: SQLConf): Value = if (conf.ansiEnabled) {
ANSI
} else {
LEGACY
}

def fromBoolean(ansiEnabled: Boolean): Value = if (ansiEnabled) {
ANSI
} else {
LEGACY
}
}

0 comments on commit a5d5ea6

Please sign in to comment.