b8caa754bc51f74ae82b5ef774a77261ef21a05e,google/datalab/bigquery/commands/_bigquery.py,,_load_cell,#Any#Any#,887

Before Change


  if not table:
    table = google.datalab.bigquery.Table(name)

  if cell_body:
    schema = google.datalab.utils.commands.parse_config(cell_body, None, False)
    jsonschema.validate(schema, table_schema_schema)
    schema = google.datalab.bigquery.Schema(schema["schema"])
    table.create(schema=schema)
  elif table.exists():
    if args["mode"] == "create":
      raise Exception("%s already exists; use --append or --overwrite" % name)
  else:
    raise Exception("Table does not exist, and no schema specified in cell; cannot load")

  csv_options = google.datalab.bigquery.CSVOptions(delimiter=args["delimiter"],
                                                   skip_leading_rows=args["skip"],
                                                   allow_jagged_rows=not args["strict"],
                                                   quote=args["quote"])

After Change


  if args["mode"] == "create":
    if table.exists():
      raise Exception("table %s already exists; use "append" or "overwrite" as mode." % name)
    if not cell_body or "schema" not in cell_body:
      raise Exception("Table does not exist, and no schema specified in cell; cannot load.")

    env = google.datalab.utils.commands.notebook_environment()
    config = google.datalab.utils.commands.parse_config(cell_body, env, False)
    schema = config["schema"]
    // schema can be an instance of google.datalab.bigquery.Schema.
    // For example, user can run "my_schema = bq.Schema.from_data(df)" in a previous cell and
    // specify "schema: $my_schema" in cell input.
    if not isinstance(schema, google.datalab.bigquery.Schema):
      jsonschema.validate(config, table_schema_schema)
      schema = google.datalab.bigquery.Schema(schema)
    table.create(schema=schema)
  elif not table.exists():
    raise Exception("table %s does not exist; use "create" as mode." % name)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: googledatalab/pydatalab
Commit Name: b8caa754bc51f74ae82b5ef774a77261ef21a05e
Time: 2017-09-11
Author: qimingj@users.noreply.github.com
File Name: google/datalab/bigquery/commands/_bigquery.py
Class Name:
Method Name: _load_cell


Project Name: home-assistant/home-assistant
Commit Name: c459789c09c996cb7cf2edcceb8f471867fbcf6a
Time: 2021-03-29
Author: erik@montnemery.com
File Name: homeassistant/components/cover/device_trigger.py
Class Name:
Method Name: async_get_trigger_capabilities


Project Name: tensorflow/transform
Commit Name: 687e31d276db17b4ac7bea08b01c1e5401168ca9
Time: 2019-01-23
Author: tf-transform-dev@google.com
File Name: tensorflow_transform/tf_metadata/metadata_io.py
Class Name:
Method Name: read_metadata