Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] adding a validation definition creates a file without a file extension #10484

Closed
JBarti opened this issue Oct 8, 2024 · 1 comment · Fixed by #10523
Closed

[BUG] adding a validation definition creates a file without a file extension #10484

JBarti opened this issue Oct 8, 2024 · 1 comment · Fixed by #10523
Labels
bug Bugs bugs bugs!

Comments

@JBarti
Copy link

JBarti commented Oct 8, 2024

Describe the bug
When creating a new validation definition in a local filesystem data context, the file created in the context directory ends up without a file extension (.json).

To Reproduce
Please include your great_expectations.yml config, the code you’re executing that causes the issue, and the full stack trace of any error(s).

great_expectations.yaml:

config_version: 4.0


config_variables_file_path: uncommitted/config_variables.yml
plugins_directory: plugins/

stores:
  expectations_store:
    class_name: ExpectationsStore
    store_backend:
      class_name: TupleFilesystemStoreBackend
      base_directory: expectations/

  validation_results_store:
    class_name: ValidationResultsStore
    store_backend:
      class_name: TupleFilesystemStoreBackend
      base_directory: uncommitted/validations/

  checkpoint_store:
    class_name: CheckpointStore
    store_backend:
      class_name: TupleFilesystemStoreBackend
      suppress_store_backend_id: true
      base_directory: checkpoints/

  validation_definition_store:
    class_name: ValidationDefinitionStore
    store_backend:
      class_name: TupleFilesystemStoreBackend
      base_directory: validation_definitions/

expectations_store_name: expectations_store
validation_results_store_name: validation_results_store
checkpoint_store_name: checkpoint_store

data_docs_sites:
  local_site:
    class_name: SiteBuilder
    show_how_to_buttons: true
    store_backend:
      class_name: TupleFilesystemStoreBackend
      base_directory: uncommitted/data_docs/local_site/
    site_index_builder:
      class_name: DefaultSiteIndexBuilder

analytics_enabled: true
fluent_datasources:
  bq_podravka_facebook:
    type: sql
    id: 009655e5-5011-44b4-8a06-b78f3a1227c0
    assets:
      basic_campaigns:
        type: table
        id: d85b4659-6de8-41eb-85f8-0f5384e79b1e
        batch_metadata: {}
        batch_definitions:
          monthly:
            id: d48fdab0-0e5a-4a7f-a0c3-2262b616d00e
            partitioner:
              column_name: date_start
              sort_ascending: true
              method_name: partition_on_year_and_month
        table_name: basic_campaigns
        schema_name:
    connection_string: ${PODRAVKA_FB_DATASET_CONNECTION_ID}
data_context_id: 9ce6b16c-ccc7-4cb9-85f1-0524be5e66c1

code:

import great_expectations as gx
from great_expectations.core.partitioners import ColumnPartitionerMonthly
from great_expectations.core.validation_definition import BatchDefinition
from great_expectations.datasource.fluent.sql_datasource import TableAsset
from great_expectations.exceptions import DataContextError

import logging

logging.getLogger().setLevel(logging.DEBUG)

context = gx.get_context(
    mode="file",
    project_root_dir="./context"
)

# Add a new data source
datasource_name = "bq_podravka_facebook"
data_source = context.data_sources.add_or_update_sql(
    name=datasource_name,
    connection_string="bigquery://project-id/dataset-id"
)

# Create a Table Asset
asset_name = "basic_campaigns"
database_table_name = "basic_campaigns"
table_data_asset: TableAsset
table_data_asset = data_source.add_table_asset(
    name=asset_name,
    table_name=database_table_name, 
)

# Monthly batch definition
date_column = "date_start"
monthly_batch_definition = table_data_asset.add_batch_definition_monthly(
    name="monthly", column=date_column
)
monthly_batch_definition: BatchDefinition[ColumnPartitionerMonthly]

# Create a suite
suite_name = "uniqueness"
suite = gx.ExpectationSuite(name=suite_name)
# Avoid adding the same suite twice
try:
    suite = context.suites.get(suite_name)
except DataContextError:
    suite = context.suites.add(suite)


# Define expectations for a suite
expectations = [
    gx.expectations.ExpectCompoundColumnsToBeUnique(
        column_list=["date_start", "campaign_id", "account_id"], # Primary key
    )
]
# Clear the expectations before adding them again
suite.expectations.clear()
for expectation in expectations:
    suite.expectations.append(expectation)
suite.save()

# Create a Validation Definition
validation_name = "basic_campaigns_monthly_uniqueness"
validation_definition = gx.ValidationDefinition(
    data=monthly_batch_definition,
    suite=suite,
    name=validation_name,
)
context.validation_definitions.add(validation_definition)

Expected behavior
The creation of a validation should result in a file named:

  • context/gx/validation_definitions/basic_campaigns_monthly_uniqueness.json

But the suffix is not added which results in a file named:

  • context/gx/validation_definitions/basic_campaigns_monthly_uniqueness

Environment (please complete the following information):

  • Operating System: MacOS
  • Great Expectations Version: 1.0.3
  • Data Source: BigQuery
  • Cloud environment: /
@JBarti JBarti changed the title [BUG] adding a validation definition creates a file without an extension [BUG] adding a validation definition creates a file without a file extension Oct 8, 2024
@adeola-ak adeola-ak moved this from To Do to In progress in GX Core Issues Board Oct 15, 2024
@adeola-ak adeola-ak added the bug Bugs bugs bugs! label Oct 15, 2024
@adeola-ak
Copy link
Contributor

hi @JBarti, thank you for bringing this to our attention. We’re aware of the issue and are working on a fix. While I don’t have an exact timeline for when it will be resolved, feel free to check back for updates soon

@github-project-automation github-project-automation bot moved this from In progress to Completed in GX Core Issues Board Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs bugs bugs!
Projects
Archived in project
2 participants