key_columns = [F.col(column_name) for column_name in self.config.deduplication_key_columns] order_by_columns = [F.col(column_name).desc() for column_name in self.config.deduplication_order_columns] if self.config.deduplicate_order_by_type == "asc": order_by_columns = [F.col(column_name) for column_name in self.config.deduplication_order_columns] ranking_column = "duplicates_rank" is_deleted_column = "IsDeleted" if (self.config.filter_deleted_flag) & ( is_deleted_column in df.columns): # if True removes records that marked deleted filter = (F.col(ranking_column) == 1) & (F.col(is_deleted_column) == "False") else: self.logger.warning(f"Records marked as deleted will be loaded to {self.config.table_full_name} table!") filter = F.col(ranking_column) == 1这里能看出源数据是怎么样的df结构,给我一个例子,并且告诉我sql怎么筛选df的列出来
时间: 2024-03-20 13:39:11 浏览: 61
假设源数据`df`的列名和数据如下:
```
+----+-------+--------+-----------+
| id | name | gender | is_deleted|
+----+-------+--------+-----------+
| 1 | Alice | female | False |
| 2 | Bob | male | False |
| 3 | Bob | male | True |
| 4 | Alice | female | True |
| 5 | Carol | female | False |
+----+-------+--------+-----------+
```
则根据Python代码,可以使用以下SQL语句筛选出`key_columns`和`is_deleted_column`所对应的列:
```
SELECT id, name, gender, is_deleted
FROM source_table;
```
即将`source_table`替换为源数据表的表名,将`id, name, gender, is_deleted`替换为`self.config.deduplication_key_columns`和`is_deleted_column`所对应的列名,即可筛选出指定的列。
阅读全文