Skip to content

Commit

Permalink
Fix Simple Expression issue where column arguments weren't resolved. (#…
Browse files Browse the repository at this point in the history
…10658)

Closes #10657

Was missing the `table.resolve` for arguments.
  • Loading branch information
jdunkerley authored Jul 24, 2024
1 parent c6da3a9 commit 7e08702
Showing 1 changed file with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ type Simple_Expression
input_column = table.resolve_as_column self.input
derived = case self.operation of
Simple_Calculation.Copy -> input_column . rename (input_column.name+" (Copy)")
Simple_Calculation.Text operation -> operation.evaluate input_column
Simple_Calculation.Math operation -> operation.evaluate input_column
Simple_Calculation.Date operation -> operation.evaluate input_column
Simple_Calculation.Logical operation -> operation.evaluate input_column
Simple_Calculation.Text operation -> operation.evaluate input_column table
Simple_Calculation.Math operation -> operation.evaluate input_column table
Simple_Calculation.Date operation -> operation.evaluate input_column table
Simple_Calculation.Logical operation -> operation.evaluate input_column table
Simple_Calculation.Add rhs -> input_column + (table.resolve rhs)
Simple_Calculation.Subtract rhs -> input_column - (table.resolve rhs)
Simple_Calculation.Multiply rhs -> input_column * (table.resolve rhs)
Expand Down Expand Up @@ -132,16 +132,16 @@ type Text_Operation

## PRIVATE
Evaluate the operation - will be passed a Column or DB_Column
evaluate : Any -> Any
evaluate self column =
evaluate : Any -> Table_Ref -> Any
evaluate self column table:Table_Ref =
case self of
Text_Operation.Left length -> column.text_left length
Text_Operation.Right length -> column.text_right length
Text_Operation.Left length -> column.text_left (table.resolve length)
Text_Operation.Right length -> column.text_right (table.resolve length)
Text_Operation.Length -> column.text_length
Text_Operation.Trim where what -> column.trim where what
Text_Operation.Starts_With prefix -> column.starts_with prefix
Text_Operation.Ends_With suffix -> column.ends_with suffix
Text_Operation.Contains substring -> column.contains substring
Text_Operation.Trim where what -> column.trim (table.resolve where) (table.resolve what)
Text_Operation.Starts_With prefix -> column.starts_with (table.resolve prefix)
Text_Operation.Ends_With suffix -> column.ends_with (table.resolve suffix)
Text_Operation.Contains substring -> column.contains (table.resolve substring)

## Defines a set of Math based operations.
type Math_Operation
Expand Down Expand Up @@ -192,14 +192,14 @@ type Math_Operation

## PRIVATE
Evaluate the operation - will be passed a Column or DB_Column
evaluate : Any -> Any
evaluate self column =
evaluate : Any -> Table_Ref -> Any
evaluate self column table:Table_Ref =
case self of
Math_Operation.Subtract rhs -> column - rhs
Math_Operation.Multiply rhs -> column * rhs
Math_Operation.Divide rhs -> column / rhs
Math_Operation.Mod rhs -> column % rhs
Math_Operation.Power rhs -> column ^ rhs
Math_Operation.Subtract rhs -> column - (table.resolve rhs)
Math_Operation.Multiply rhs -> column * (table.resolve rhs)
Math_Operation.Divide rhs -> column / (table.resolve rhs)
Math_Operation.Mod rhs -> column % (table.resolve rhs)
Math_Operation.Power rhs -> column ^ (table.resolve rhs)
Math_Operation.Round precision use_bankers -> column.round precision use_bankers
Math_Operation.Ceil -> column.ceil
Math_Operation.Floor -> column.floor
Expand Down Expand Up @@ -258,12 +258,12 @@ type Date_Operation

## PRIVATE
Evaluate the operation - will be passed a Column or DB_Column
evaluate : Any -> Any
evaluate self column =
evaluate : Any -> Table_Ref -> Any
evaluate self column table:Table_Ref =
case self of
Date_Operation.Add length period -> column.date_add length period
Date_Operation.Add length period -> column.date_add (table.resolve length) period
Date_Operation.Part period -> column.date_part period
Date_Operation.Diff end period -> column.date_diff end period
Date_Operation.Diff end period -> column.date_diff (table.resolve end) period
Date_Operation.Truncate -> column.truncate
Date_Operation.Year -> column.year
Date_Operation.Month -> column.month
Expand Down Expand Up @@ -296,12 +296,12 @@ type Logical_Operation

## PRIVATE
Evaluate the operation - will be passed a Column or DB_Column
evaluate : Any -> Any
evaluate self column =
evaluate : Any -> Table_Ref -> Any
evaluate self column table:Table_Ref =
case self of
Logical_Operation.Not -> column.not
Logical_Operation.And rhs -> column && rhs
Logical_Operation.Or rhs -> column || rhs
Logical_Operation.And rhs -> column && (table.resolve rhs)
Logical_Operation.Or rhs -> column || (table.resolve rhs)

## Defines the operation on a derived column.
type Simple_Calculation
Expand Down

0 comments on commit 7e08702

Please sign in to comment.