You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/synapse-analytics/spark/apache-spark-external-metastore.md
+21-14Lines changed: 21 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,11 @@ The feature works with Spark 3.1. The following table shows the supported Hive M
33
33
34
34
Follow below steps to set up a linked service to the external Hive Metastore in Synapse workspace.
35
35
36
-
1. Open Synapse Studio, go to **Manage > Linked services** at left, click**New** to create a new linked service.
36
+
1. Open Synapse Studio, go to **Manage > Linked services** at left, select**New** to create a new linked service.
37
37
38
38
:::image type="content" source="./media/use-external-metastore/set-up-hive-metastore-linked-service.png" alt-text="Set up Hive Metastore linked service" border="true":::
39
39
40
-
2. Choose **Azure SQL Database** or **Azure Database for MySQL** based on your database type, click**Continue**.
40
+
2. Choose **Azure SQL Database** or **Azure Database for MySQL** based on your database type, select**Continue**.
41
41
42
42
3. Provide **Name** of the linked service. Record the name of the linked service, this info will be used to configure Spark shortly.
43
43
@@ -47,14 +47,19 @@ Follow below steps to set up a linked service to the external Hive Metastore in
47
47
48
48
6.**Test connection** to verify the username and password.
49
49
50
-
7.Click**Create** to create the linked service.
50
+
7.Select**Create** to create the linked service.
51
51
52
52
### Test connection and get the metastore version in notebook
53
-
Some network security rule settings may block access from Spark pool to the external Hive Metastore DB. Before you configure the Spark pool, run below code in any Spark pool notebook to test connection to the external Hive Metastore DB.
53
+
54
+
Some network security rule settings could block access from Spark pool to the external Hive Metastore DB. Before you configure the Spark pool, run below code in any Spark pool notebook to test connection to the external Hive Metastore DB.
54
55
55
56
You can also get your Hive Metastore version from the output results. The Hive Metastore version will be used in the Spark configuration.
56
57
58
+
>[!WARNING]
59
+
>Don't publish the test scripts in your notebook with your password hardcoded as this could cause a potential security risk for your Hive Metastore.
60
+
57
61
#### Connection testing code for Azure SQL
62
+
58
63
```scala
59
64
%%spark
60
65
importjava.sql.DriverManager
@@ -71,6 +76,7 @@ try {
71
76
```
72
77
73
78
#### Connection testing code for Azure Database for MySQL
79
+
74
80
```scala
75
81
%%spark
76
82
importjava.sql.DriverManager
@@ -87,7 +93,8 @@ try {
87
93
```
88
94
89
95
## Configure Spark to use the external Hive Metastore
90
-
After creating the linked service to the external Hive Metastore successfully, you need to set up a few Spark configurations to use the external Hive Metastore. You can both set up the configuration at Spark pool level, or at Spark session level.
96
+
97
+
After creating the linked service to the external Hive Metastore successfully, you need to set up a few Spark configurations to use the external Hive Metastore. You can both set up the configuration at Spark pool level, or at Spark session level.
91
98
92
99
Here are the configurations and descriptions:
93
100
@@ -96,7 +103,7 @@ Here are the configurations and descriptions:
96
103
97
104
|Spark config|Description|
98
105
|--|--|
99
-
|`spark.sql.hive.metastore.version`|Supported versions: <ul><li>`2.3`</li><li>`3.1`</li></ul> Make sure you use the first 2 parts without the 3rd part|
106
+
|`spark.sql.hive.metastore.version`|Supported versions: <ul><li>`2.3`</li><li>`3.1`</li></ul> Make sure you use the first two parts without the third part|
For notebook session, you can also configure the Spark session in notebook using `%%configure` magic command. Here is the code.
136
+
For notebook session, you can also configure the Spark session in notebook using `%%configure` magic command. Here's the code.
130
137
131
138
```json
132
139
%%configure -f
@@ -165,10 +172,10 @@ If the underlying data of your Hive tables are stored in Azure Blob storage acco
165
172
166
173
:::image type="content" source="./media/use-external-metastore/connect-to-storage-account.png" alt-text="Connect to storage account" border="true":::
167
174
168
-
2. Choose **Azure Blob Storage** and click**Continue**.
175
+
2. Choose **Azure Blob Storage** and select**Continue**.
169
176
3. Provide **Name** of the linked service. Record the name of the linked service, this info will be used in Spark configuration shortly.
170
177
4. Select the Azure Blob Storage account. Make sure Authentication method is **Account key**. Currently Spark pool can only access Blob Storage account via account key.
171
-
5.**Test connection** and click**Create**.
178
+
5.**Test connection** and select**Create**.
172
179
6. After creating the linked service to Blob Storage account, when you run Spark queries, make sure you run below Spark code in the notebook to get access to the Blob Storage account for the Spark session. Learn more about why you need to do this [here](./apache-spark-secure-credentials-with-tokenlibrary.md).
173
180
174
181
```python
@@ -190,7 +197,7 @@ After setting up storage connections, you can query the existing tables in the H
190
197
-[SQL <-> Spark synchronization](../sql/develop-storage-files-spark-tables.md) doesn't work when using external HMS.
191
198
- Only Azure SQL Database and Azure Database for MySQL are supported as external Hive Metastore database. Only SQL authorization is supported.
192
199
- Currently Spark only works on external Hive tables and non-transactional/non-ACID managed Hive tables. It doesn't support Hive ACID/transactional tables.
193
-
- Apache Ranger integration is not supported.
200
+
- Apache Ranger integration isn't supported.
194
201
195
202
## Troubleshooting
196
203
### See below error when querying a Hive table with data stored in Blob Storage
If you need to migrate your HMS version, we recommend using [hive schema tool](https://cwiki.apache.org/confluence/display/Hive/Hive+Schema+Tool). And if the HMS has been used by HDInsight clusters, we suggest using [HDI provided version](../../hdinsight/interactive-query/apache-hive-migrate-workloads.md).
238
245
239
246
### HMS schema change for OSS HMS 3.1
240
-
Synapse aims to work smoothly with computes from HDI. However HMS 3.1 in HDI 4.0 is not fully compatible with the OSS HMS 3.1. So please apply the following manually to your HMS 3.1 if it’s not provisioned by HDI.
247
+
Synapse aims to work smoothly with computes from HDI. However HMS 3.1 in HDI 4.0 isn't fully compatible with the OSS HMS 3.1. Apply the following manually to your HMS 3.1 if it’s not provisioned by HDI.
### When sharing the metastore with HDInsight 4.0 Spark cluster, I cannot see the tables
249
-
If you want to share the Hive catalog with a spark cluster in HDInsight 4.0, please ensure your property `spark.hadoop.metastore.catalog.default` in Synapse spark aligns with the value in HDInsight spark. The default value for HDI spark is `spark` and the default value for Synapse spark is `hive`.
255
+
### When sharing the metastore with HDInsight 4.0 Spark cluster, I can't see the tables
256
+
If you want to share the Hive catalog with a spark cluster in HDInsight 4.0, ensure your property `spark.hadoop.metastore.catalog.default` in Synapse spark aligns with the value in HDInsight spark. The default value for HDI spark is `spark` and the default value for Synapse spark is `hive`.
250
257
251
258
### When sharing the Hive Metastore with HDInsight 4.0 Hive cluster, I can list the tables successfully, but only get empty result when I query the table
252
259
As mentioned in the limitations, Synapse Spark pool only supports external hive tables and non-transactional/ACID managed tables, it doesn't support Hive ACID/transactional tables currently. In HDInsight 4.0 Hive clusters, all managed tables are created as ACID/transactional tables by default, that's why you get empty results when querying those tables.
0 commit comments