Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonwang-db committed Dec 30, 2024
1 parent 69a9c0f commit 81cc535
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5637,7 +5637,7 @@
},
"NOT_NULL_ON_FUNCTION_PARAMETERS" : {
"message" : [
"Cannot specify NOT NULL on <languageName> function parameters: <input>"
"Cannot specify NOT NULL on function parameters: <input>"
]
},
"RETURN_COLUMN_COUNT_MISMATCH" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ object UserDefinedFunctionErrors extends QueryErrorsBase {
messageParameters = Map("routineName" -> routineName, "columns" -> columns))
}

def cannotSpecifyNotNullOnFunctionParameters(
language: RoutineLanguage, input: String): Throwable = {
def cannotSpecifyNotNullOnFunctionParameters(input: String): Throwable = {
new AnalysisException(
errorClass = "USER_DEFINED_FUNCTIONS.NOT_NULL_ON_FUNCTION_PARAMETERS",
messageParameters = Map("languageName" -> language.name, "input" -> input))
messageParameters = Map("input" -> input))
}

def bodyIsNotAQueryForSqlTableUdf(functionName: String): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ case class CreateSQLFunctionCommand(
// Build function input.
val inputPlan = if (inputParam.isDefined) {
val param = inputParam.get
checkParameterNotNull(param, inputParamText.get, function.language)
checkParameterNotNull(param, inputParamText.get)
checkParameterNameDuplication(param, conf, name)
checkDefaultsTrailing(param, name)

Expand Down Expand Up @@ -209,7 +209,7 @@ case class CreateSQLFunctionCommand(
}

// Check the return columns cannot have NOT NULL specified.
checkParameterNotNull(returnParam, returnTypeText, function.language)
checkParameterNotNull(returnParam, returnTypeText)

// Check duplicated return column names.
checkReturnsColumnDuplication(returnParam, conf, name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ object CreateUserDefinedFunctionCommand {
* Perform this check on function input and return parameters while registering the function
* to fail early. This check does not need to run the function itself.
*/
def checkParameterNotNull(param: StructType, input: String, language: RoutineLanguage): Unit = {
def checkParameterNotNull(param: StructType, input: String): Unit = {
param.fields.foreach { field =>
if (!field.nullable) {
throw UserDefinedFunctionErrors.cannotSpecifyNotNullOnFunctionParameters(language, input)
throw UserDefinedFunctionErrors.cannotSpecifyNotNullOnFunctionParameters(input)
}
}
}
Expand Down

0 comments on commit 81cc535

Please sign in to comment.