Skip to content

Commit

Permalink
fix: Add __eq__, __hash__ to SparkSource for comparision
Browse files Browse the repository at this point in the history
Signed-off-by: tanlocnguyen <[email protected]>
  • Loading branch information
ElliotNguyen68 committed Mar 21, 2024
1 parent 8eb0c59 commit b7a060d
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,36 @@ def get_table_query_string(self) -> str:
df.createOrReplaceTempView(tmp_table_name)

return f"`{tmp_table_name}`"

def __eq__(self, other):
if other is None:
return False

if not isinstance(other, SparkSource):
raise TypeError("Comparisons should only involve SparkSource class objects.")

if (
self.name != other.name
or self.timestamp_field != other.timestamp_field
or self.created_timestamp_column != other.created_timestamp_column
or self.field_mapping != other.field_mapping
or self.date_partition_column != other.date_partition_column
or self.description != other.description
or self.tags != other.tags
or self.owner != other.owner
):
return False
if self.table != other.table:
return False
if self.query != other.query:
return False
if self.path != other.path:
return False

return True

def __hash__(self):
return super().__hash__()


class SparkOptions:
Expand Down

0 comments on commit b7a060d

Please sign in to comment.