Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MarkPryceMaherMSFT/5967354f740fb388f17c13d02c3b6d07 to your computer and use it in GitHub Desktop.
Save MarkPryceMaherMSFT/5967354f740fb388f17c13d02c3b6d07 to your computer and use it in GitHub Desktop.
Fabric Notebook to create a case-insensitive collation warehouse
Display the source blob
Display the rendered blob
Raw
{"cells":[{"cell_type":"code","source":["# Notebook to create a warehouse in a case insensitive collation\n","import json\n","import sempy.fabric as fabric\n","from sempy.fabric.exceptions import FabricHTTPException, WorkspaceNotFoundException\n","\n","workspace_id=spark.conf.get(\"trident.workspace.id\")\n","\n","#Instantiate the client\n","client = fabric.FabricRestClient()\n","\n","uri = f\"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items\"\n","payload = { \n"," \"type\": \"Warehouse\", \n"," \"displayName\": \"warehousename2\", ## replace with the name of your data warehouse\n"," \"description\": \"New warehouse with case-insensitive collation\", \n"," \"creationPayload\": { \n"," \"defaultCollation\": \"Latin1_General_100_CI_AS_KS_WS_SC_UTF8\" \n"," } \n","}\n","\n","# Call the REST API\n","response = client.post(uri,json= payload)\n","display(response)\n","\n","# 202 is the expected result"],"outputs":[{"output_type":"display_data","data":{"application/vnd.livy.statement-meta+json":{"spark_pool":null,"statement_id":5,"statement_ids":[5],"state":"finished","livy_statement_state":"available","session_id":"bd9cde8e-5629-45b4-a41f-ce05dbed1d78","normalized_state":"finished","queued_time":"2024-10-17T11:04:53.7352875Z","session_start_time":null,"execution_start_time":"2024-10-17T11:04:54.1509954Z","execution_finish_time":"2024-10-17T11:04:55.1696732Z","parent_msg_id":"70619562-247d-4ad0-a3be-5ea1a0edf5dc"},"text/plain":"StatementMeta(, bd9cde8e-5629-45b4-a41f-ce05dbed1d78, 5, Finished, Available, Finished)"},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"<Response [202]>"},"metadata":{}}],"execution_count":3,"metadata":{"microsoft":{"language":"python","language_group":"synapse_pyspark"}},"id":"d1bb4ddf-a194-453b-829f-17ea2de421b8"}],"metadata":{"kernel_info":{"name":"synapse_pyspark"},"kernelspec":{"name":"synapse_pyspark","language":"Python","display_name":"Synapse PySpark"},"language_info":{"name":"python"},"microsoft":{"language":"python","language_group":"synapse_pyspark","ms_spell_check":{"ms_spell_check_language":"en"}},"widgets":{},"nteract":{"version":"[email protected]"},"spark_compute":{"compute_id":"/trident/default","session_options":{"conf":{"spark.synapse.nbs.session.timeout":"1200000"}}},"dependencies":{"lakehouse":{"default_lakehouse":"5420f72f-27a3-4635-855c-c1404510f319","known_lakehouses":[{"id":"5420f72f-27a3-4635-855c-c1404510f319"}],"default_lakehouse_name":"lake1","default_lakehouse_workspace_id":"9067c4dc-4ae6-4ae7-b14f-14e97fc8de79"}}},"nbformat":4,"nbformat_minor":5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment