Open msyyc opened 1 year ago
The root cause is last_rest_key_case_insensitive_extractor:
If we remove it from key_extractors
, the bug is fixed. But according to function description, the extractor is by design. So add @lmazuel for more context.
First, the Swagger is broken, as it defines multiple schema
as the same level. Honestly, we should have a Swagger linter error to refuse this Swagger. M4 is nice and rename the inner one schema_type_properties_schema
, but it's still messed up Swagger.
Details:
AzureSqlTable
, send us to the discriminated type AzureSqlTableDataset
: https://github.com/Azure/azure-rest-api-specs/blob/5b51ccefb0ba7799bbeac5e5460d9eec84ce55fa/specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/entityTypes/Dataset.json#L1073C6-L1073C26typeProperties
, that contains a schema
as well: https://github.com/Azure/azure-rest-api-specs/blob/5b51ccefb0ba7799bbeac5e5460d9eec84ce55fa/specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/entityTypes/Dataset.json#L1097typeProperties
is flattened: https://github.com/Azure/azure-rest-api-specs/blob/5b51ccefb0ba7799bbeac5e5460d9eec84ce55fa/specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/entityTypes/Dataset.json#L1085This means that AzureSqlTableDataset
contains two schema properties at the same level conceptually.
The problem here, is that when receiving a dict, msrest tries to first rebuild a model, and then re-serialize this model. When rebuilding the model, it introspects into key that looks like attribute, and find two schema
.
Long story short, this problem wouldn't occur from model directly, it's only happening with the dict syntax. The fix is not obvious, and may not be possible, because we're already in an ambiguous place with this Swagger. I'll take a look when I can.
swagger definition: https://github.com/Azure/azure-rest-api-specs/blob/5b51ccefb0ba7799bbeac5e5460d9eec84ce55fa/specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/datafactory.json#L6284-L6300
Python SDK model: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/datafactory/azure-mgmt-datafactory/azure/mgmt/datafactory/models/_models_py3.py#L20345
reproduce:
subscription_id = ""
credential = DefaultAzureCredential()
data_factory_name = ""
adf_client = DataFactoryManagementClient(credential, subscription_id) dataset_name = "test_dataset" dataset = { "properties": { "type": "AzureSqlTable", "schema": "xxx" } }
serialization = adf_client.datasets._serialize.body(dataset, "DatasetResource") print(serialization)