Skip to content

Commit

Permalink
Merge branch 'refs/heads/devel' into 1370-lancedb-destination
Browse files Browse the repository at this point in the history
  • Loading branch information
Pipboyguy committed May 17, 2024
2 parents 0f3d57f + 4c6f928 commit 69e1daa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dlt/destinations/impl/mssql/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _get_column_def_sql(self, c: TColumnSchema, table_format: TTableFormat = Non
if c.get(h, False) is True
)
column_name = self.capabilities.escape_identifier(c["name"])
return f"{column_name} {db_type} {hints_str} {self._gen_not_null(c['nullable'])}"
return f"{column_name} {db_type} {hints_str} {self._gen_not_null(c.get('nullable', True))}"

def _create_replace_followup_jobs(
self, table_chain: Sequence[TTableSchema]
Expand Down
15 changes: 6 additions & 9 deletions dlt/extract/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,13 @@ def _wrap(*args: Any, **kwargs: Any) -> TDltResourceImpl:
compat_wrapper(actual_resource_name, conf_f, sig, *args, **kwargs),
incremental,
)
except InvalidResourceDataTypeFunctionNotAGenerator as gen_ex:
except InvalidResourceDataTypeFunctionNotAGenerator:
# we allow an edge case: resource can return another resource
try:
# actually call the function to see if it contains DltResource
data_ = conf_f(*args, **kwargs)
if not isinstance(data_, DltResource):
raise
r = data_ # type: ignore[assignment]
except Exception:
raise gen_ex from None
# actually call the function to see if it contains DltResource
data_ = conf_f(*args, **kwargs)
if not isinstance(data_, DltResource):
raise
r = data_ # type: ignore[assignment]
# consider transformer arguments bound
r._args_bound = True
# keep explicit args passed
Expand Down
11 changes: 11 additions & 0 deletions tests/extract/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,17 @@ def rv_resource(name: str):
assert list(r) == [1, 2, 3]


def test_standalone_resource_returning_resource_exception() -> None:
@dlt.resource(standalone=True)
def rv_resource(uniq_name: str = dlt.config.value):
return dlt.resource([1, 2, 3], name=uniq_name, primary_key="value")

# pass through of the exception in `rv_resource` when it returns, not yields
with pytest.raises(ConfigFieldMissingException) as conf_ex:
rv_resource()
assert conf_ex.value.fields == ["uniq_name"]


def test_resource_rename_credentials_separation():
os.environ["SOURCES__TEST_DECORATORS__STANDALONE_SIGNATURE__SECRET_END"] = "5"
assert list(standalone_signature(1)) == [1, 2, 3, 4]
Expand Down

0 comments on commit 69e1daa

Please sign in to comment.