Kelola Komponen

Pengantar Data Quality dengan Great Expectations

Davina Moossazadeh

Data Scientist

Komponen

Komponen GX - Kelas Python yang merepresentasikan entitas data dan validasi data

  • Data Context
  • Data Source & Data Asset
  • Batch Definition & Batch
  • Expectation
  • Expectation Suite
  • Validation Definition
  • Checkpoint & Action
  • Data Docs
1 https://docs.greatexpectations.io/docs/core/introduction/gx_overview
Pengantar Data Quality dengan Great Expectations

Manajemen komponen di GX

Data Source:

  • terhubung ke data dan memuat Data Asset

Expectation Suite:

  • berisi Expectation

Validation Definition:

  • memvalidasi Expectation terhadap data

Checkpoint:

  • mengelompokkan dan mengotomatisasi Validation

context.data_sources

$$

context.suites

$$

context.validation_definitions

$$

context.checkpoints

Pengantar Data Quality dengan Great Expectations

Menambahkan komponen

Expectation Suite:

suite = context.suites.add(suite)

Validation Definition:

validation_definition = context.validation_definitions.add(validation_definition)

Checkpoint:

checkpoint = context.checkpoints.add(
    checkpoint=checkpoint
)
Pengantar Data Quality dengan Great Expectations

Menambahkan Data Source

data_source = context.data_sources.add_<TYPE_NAME>()

1 https://docs.greatexpectations.io/docs/core/connect_to_data/
Pengantar Data Quality dengan Great Expectations

Menambahkan Data Source pandas

Gunakan .add_pandas() untuk menyiapkan Data Source untuk DataFrame pandas dengan mudah:

data_source = context.data_sources.add_pandas(
    name="my_pandas_datasource"
)
Pengantar Data Quality dengan Great Expectations

Mengambil komponen

Ambil komponen dengan .get() dengan menyebutkan parameter name:

context.<COMPONENT>s.get(

name: str )
data_source = context.data_sources.get(

name="my_pandas_datasource" )
print(data_source)
id: 46c91f1b-1db9-4351-b5dd-83e038c0f511
name: 'my_pandas_datasource'
type: pandas
Pengantar Data Quality dengan Great Expectations

Mengambil komponen

Data Source:

context.data_sources.get(
    name="my_pandas_datasource"
)

Expectation Suite:

context.suites.get(
    name="my_suite"
)

Validation Definition:

context.validation_definitions.get(
    name="my_validation_definition"
)

Checkpoint:

context.checkpoints.get(
    name="my_checkpoint"
)
Pengantar Data Quality dengan Great Expectations

Menampilkan daftar komponen

Gunakan .all() untuk menampilkan semua komponen dalam Data Context, termasuk nama dan metadata:

context.<COMPONENT>s.all()
data_sources = context.data_sources.all()

print(data_sources)
{
    'my_pandas_datasource': PandasDatasource(
        type='pandas',
        name='my_pandas_datasource', 
        id=UUID('c22b16f7-6945-400e-932f-026cbd63b112'), 
        assets=[]
    )
}
Pengantar Data Quality dengan Great Expectations

Menampilkan daftar komponen

Data Source:

context.data_sources.all()

Expectation Suite:

context.suites.all()

Validation Definition:

context.validation_definitions.all()

Checkpoint:

context.checkpoints.all()
Pengantar Data Quality dengan Great Expectations

Menghapus komponen

Gunakan .delete() untuk menghapus komponen dengan menyebutkan namanya:

context.<COMPONENT>s.delete(

name: str )
context.data_sources.delete(
    name="my_pandas_datasource"
)

print(context.data_sources.all())
{}
Pengantar Data Quality dengan Great Expectations

Menghapus komponen

Data Source:

context.data_sources.delete(
    name="my_pandas_datasource"
)

Expectation Suite:

context.suites.delete(
    name="my_suite"
)

Validation Definition:

context.validation_definitions.delete(
    name="my_validation_definition"
)

Checkpoint:

context.checkpoints.delete(
    name="my_checkpoint"
)
Pengantar Data Quality dengan Great Expectations

Ringkasan cepat

Tambahkan komponen ke Data Context:

context.data_sources.add(data_source)

context.suites.add(suite)

context.validation_definitions.add(
    validation_definition
)

context.checkpoints.add(checkpoint)

Ambil komponen:

.get(name: str)

Daftar komponen:

.all()

Hapus komponen:

.delete(name: str)
Pengantar Data Quality dengan Great Expectations

Ayo berlatih!

Pengantar Data Quality dengan Great Expectations

Preparing Video For Download...