Hey I am looking at this tap <https://hub.meltano....
# singer-tap-development
a
Hey I am looking at this tap https://hub.meltano.com/extractors/tap-bigquery/, when installing it creates a .lock file where it defines some environment variables with default values, but I cannot see where this .lock file is being originated based on the github code? is this an abstraction that meltano add does? The env variable is
GOOGLE_APPLICATION_CREDENTIALS
but I cannot find it anywhere in the python code where is being set up
Oh probably this:
Please consider adding any settings you have defined locally to this definition on MeltanoHub by making a pull request to the YAML file that defines the settings for this plugin.
👍 1
I am wondering if I can modify this behavior without having to create a PR? I do not want this env variable to be set by default https://github.com/meltano/hub/blob/main/_data/meltano/extractors/tap-bigquery/anelendata.yml#L37C38-L38C1
r
From the docs for `env`:
Use to delegate to an environment variable for overriding this setting's value.
So it should not be set when the plugin is invoked - rather it can be used to configure the setting via that environment variable. Are you seeing something different?
a
mmm i don’t want this environment variable to be set up at all, not the default value or a particular value, I dont want it to exist
its not possible atm I think
r
Why? Is it picking up a value from somewhere you don't want, or is it just a personal preference thing? You can always override the plugin
settings
in the
meltano.yml
, but you might have to re-declare all of them - not just
credentials_path
.
Alternatively, you can just edit the
.lock
file, although not recommended.
a
So it has to do how some bigquery.Client authenticates based on how that value is set, I added more details here: https://github.com/anelendata/tap-bigquery/issues/29
Mmm I am interested in how to do the setting thins in the meltano.yml that you mention
It tries to take both the settings from the .lock and merge them with the ones defined in meltano.yml or it is a complete replacement?
Because if it merges (e.g I do not define the GOOGLE_APPLICATION_CREDENTIALS variable) but it will pick up from the .lock file then I think I need to figure out another solution
r
I'm not sure how it works for nested properties, but if you look in your
meltano.yml
now, you'll see there is already an override for
pip_url
that Meltano uses over the one in the
.lock
file (they just happen to be the same value initially). I would assume you have to completely replace
settings
, but I could be wrong.
a
mmmm that’s wonderful, thanks for your time, could you just please help me understand what do you mean by completely replace?
r
Copy code
- name: tap-bigquery
  variant: anelendata
  pip_url: tap-bigquery
  settings: [
    {
      "name": "streams",
      "kind": "array",
      "label": "Streams",
      "description": "Array of objects with `name`, `table`, `columns`, `datetime_key`, and `filters` keys:\n\n- `name`: The entity name, used by most loaders as the name of the table to be created.\n- `table`: Fully qualified table name in BigQuery, with format `` `<project>.<dataset>.<table>` ``. Since backticks have special meaning in YAML, values in `meltano.yml` should be wrapped in double quotes.\n- `columns`: Array of column names to select. Using `[\"*\"]` is not recommended as it can become very expensive for a table with a large number of columns.\n- `datetime_key`: Name of datetime column to use as [replication key](<https://docs.meltano.com/guide/integration#replication-key>).\n- `filters`: Optional array of `WHERE` clauses to filter extracted data, e.g. `\"column='value'\"`.\n"
    },
    {
      "name": "credentials_path",
      "env": "GOOGLE_APPLICATION_CREDENTIALS",
      "value": "$MELTANO_PROJECT_ROOT/client_secrets.json",
      "label": "Credentials Path",
      "description": "Fully qualified path to `client_secrets.json` for your service account.\n\nSee the [\"Activate the Google BigQuery API\" section of the repository's README](<https://github.com/anelendata/tap-bigquery#step-1-activate-the-google-bigquery-api>) and <<https://cloud.google.com/docs/authentication/production>>.\n\nBy default, this file is expected to be at the root of your project directory.\n"
    },
    {
      "name": "start_datetime",
      "kind": "date_iso8601",
      "label": "Start Datetime",
      "description": "Determines how much historical data will be extracted. Please be aware that the larger the time period and amount of data, the longer the initial extraction can be expected to take."
    },
    {
      "name": "end_datetime",
      "kind": "date_iso8601",
      "label": "End Datetime",
      "description": "Date up to when historical data will be extracted."
    },
    {
      "name": "limit",
      "kind": "integer",
      "label": "Limit",
      "description": "Limits the number of records returned in each stream, applied as a limit in the query."
    },
    {
      "name": "start_always_inclusive",
      "kind": "boolean",
      "value": true,
      "label": "Start Always Inclusive",
      "description": "When replicating incrementally, disable to only select records whose `datetime_key` is greater than the maximum value replicated in the last run, by excluding records whose timestamps match exactly. This could cause records to be missed that were created after the last run finished, but during the same second and with the same timestamp."
    }
  ]
You could convert it to YAML syntax, but since YAML is a subset of JSON that should work anyway.
Just tested it - you don't have to re-declare them all, just
credentials_path
will do:
Copy code
- name: tap-bigquery
  variant: anelendata
  pip_url: tap-bigquery
  settings: [
    {
      "name": "credentials_path",
      "value": "$MELTANO_PROJECT_ROOT/client_secrets.json",
      "label": "Credentials Path",
      "description": "My `credentials_path` override"
    }
  ]
or
Copy code
- name: tap-bigquery
  variant: anelendata
  pip_url: tap-bigquery
  settings:
  - name: credentials_path
    value: $MELTANO_PROJECT_ROOT/client_secrets.json
    label: Credentials Path
    description: My `credentials_path` override
So in answer to your previous question
It tries to take both the settings from the .lock and merge them with the ones defined in meltano.yml or it is a complete replacement?
it seems to merge down to (and including)
settings
, but not the properties of an individual setting.
a
Ah so it merges down won’t work, I just want it removed… might try modifying the .lock file then 😞
r
It does work. If I exclude the
description
in my above example, I no longer see it displayed in
meltano config tap-bigquery list
. I was just saying that you have to complete replace
credentials_path
only, without all the other settings.
a
Oh sorry I missed your point then, thanks!
👍 1
r
Give it a go and see if it works. I think the docs on
env
are pretty unclear, so I suspect what you are actually seeing is that environment variable always getting set at runtime. I was confusing
env
with aliases earlier. https://github.com/meltano/meltano/issues/8600
a
It worked @Reuben (Matatika), thank you!
🔥 1
r
No problem 😉