Skip to content

executemany() does not check keyword names for an empty parameter list #1112

Closed

Description

@laughingman7743

Problem

Since #1102, execute() of the default, dict, Arrow, S3FS, and Spark cursors raises TypeError for unknown keyword arguments.
executemany() forwards its keyword arguments to execute() once per parameter set (WithFetch.executemany() in pyathena/result_set.py and WithAsyncFetch.executemany() in pyathena/aio/common.py), so with an empty seq_of_parameters the names are never checked:

cursor.executemany("INSERT INTO t VALUES (%(a)s)", [], work_gruop="typo")  # returns without error
cursor.executemany("INSERT INTO t VALUES (%(a)s)", [{"a": 1}], work_gruop="typo")  # TypeError

No query runs in the first case, so nothing is lost, but whether a typo is reported depends on the data.

Options

  1. Validate the keyword names in executemany() before the loop.
  2. Leave it as is: an empty batch executes nothing.

Found while reviewing #1102.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions