aws / aws/amazon-redshift-python-driver
The field names should be presented.
- Dominant language
- Python
- Stars
- 220
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
The generated sql code for insert do not point the field names.
Then the only way to make it work is to order the field names in the dataframe.
```
if not self.__is_valid_table(table):
raise InterfaceError("Invalid table name passed to write_dataframe: {}".format(table))
sanitized_table_name: str = self.__sanitize_str(table)
arrays: list = df.values.tolist()
placeholder: str = ", ".join(["%s"] * len(arrays[0]))
sql: str = "insert into {table} values ({placeholder})".format(
table=sanitized_table_name, placeholder=placeholder
)
```
https://github.com/aws/amazon-redshift-python-driver/blob/64cbd54ef6a5e71d98ce193630d09267cc154379/redshift_connector/cursor.py#L584C1-L591C10
Contributor guide
Research direction
Start in redshift_connector/cursor.py at the linked lines and trace the write_dataframe SQL generation. Confirm how dataframe column names are available, then verify that generated INSERT statements include field names so results no longer depend on dataframe column order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100