Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AstrakhantsevaAA committed Nov 7, 2023
1 parent 89b8e6e commit 8ad09f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ def mongodb_collection(
write_disposition: Optional[str] = dlt.config.value,
) -> Any:
# set up mongo client
client = MongoClient(
connection_url, uuidRepresentation="standard", tz_aware=True
)
mongo_database = (
client.get_default_database() if not database else client[database]
)
client = MongoClient(connection_url, uuidRepresentation="standard", tz_aware=True)
mongo_database = client.get_default_database() if not database else client[database]
collection_obj = mongo_database[collection]

def collection_documents(
Expand Down Expand Up @@ -115,9 +111,7 @@ def convert_mongo_objs(value: Any) -> Any:
print(load_info)
tables = pipeline.last_trace.last_normalize_info.row_counts # @@@DLT_REMOVE
tables.pop("_dlt_pipeline_state") # @@@DLT_REMOVE
assert (
len(tables) == 7
), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE
assert (len(tables) == 7), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE

# The second method involves setting the max_table_nesting attribute directly
# on the source data object.
Expand All @@ -137,9 +131,7 @@ def convert_mongo_objs(value: Any) -> Any:
print(load_info)
tables = pipeline.last_trace.last_normalize_info.row_counts # @@@DLT_REMOVE
tables.pop("_dlt_pipeline_state") # @@@DLT_REMOVE
assert (
len(tables) == 1
), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE
assert (len(tables) == 1), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE

# The third method involves applying data type hints to specific columns in the data.
# In this case, we tell dlt that column 'cast' (containing a list of actors)
Expand All @@ -158,9 +150,7 @@ def convert_mongo_objs(value: Any) -> Any:
print(load_info)
tables = pipeline.last_trace.last_normalize_info.row_counts # @@@DLT_REMOVE
tables.pop("_dlt_pipeline_state") # @@@DLT_REMOVE
assert (
len(tables) == 6
), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE
assert (len(tables) == 6), pipeline.last_trace.last_normalize_info # @@@DLT_REMOVE

# @@@DLT_SNIPPET_END nested_data_run
# @@@DLT_SNIPPET_END example
2 changes: 1 addition & 1 deletion docs/website/docs/examples/nested_data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords: [incremental loading, example]
import Header from '../_examples-header.md';

<Header
intro="This tutorial demonstrates how to control nested data using Python and the dlt library. It covers working with MongoDB, incremental loading, limiting nesting levels, and applying data type hints."
intro="This example demonstrates how to control nested data using Python and the dlt library. It covers working with MongoDB, incremental loading, limiting nesting levels, and applying data type hints."
slug="nested_data"
run_file="nested_data" />

Expand Down

0 comments on commit 8ad09f3

Please sign in to comment.