Skip to content

TypeError: 'AzureSqlTableDataset' object is not subscriptable #31505

Closed

Description

Getting dataset properties throwing error

#!/usr/bin/env python

from azure.identity import DefaultAzureCredential
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.mgmt.datafactory.models import DatasetResource
from azure.identity import DefaultAzureCredential
from azure.identity import ClientSecretCredential
import json

# Replace with your Azure subscription ID and resource group name
subscription_id = '<subid>'
credential = DefaultAzureCredential()
resource_group_name = "<myrg>"
data_factory_name = "<myadf>"

adf_client = DataFactoryManagementClient(credential, subscription_id)

# Define dataset properties
dataset_name = "test_dataset"
dataset = '{"properties": {"linkedServiceName": { "referenceName": "AzureSqlDatabase1","type": "LinkedServiceReference"},"type": "AzureSqlTable","folder": {"name": "azuresql_test"},"typeProperties": {"schema": "sales","table": "customers"}}}'
dataset = json.loads(dataset)
print(dataset)

# Create the dataset in the Data Factory
adf_client.datasets.create_or_update(resource_group_name, data_factory_name, dataset_name, dataset)
print("created dataset")

# Fetch the dataset schema
print("Fetch the dataset schema")
dataset = adf_client.datasets.get(resource_group_name, data_factory_name, dataset_name)
print('dataset', dataset)
schema = dataset.properties["typeProperties"]["schema"]

# Now you can use the 'schema' dictionary to get information about column names, data types, etc.
print(schema)

Dataset created but I am getting error, while fetching the dataset schema,
TypeError: 'AzureSqlTableDataset' object is not subscriptable


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Data FactoryMgmtThis issue is related to a management-plane library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions