File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,7 @@ Supported read options:
218218- ` client_id ` (string, required) - Application ID (client ID) of Azure Service Principal
219219- ` client_secret ` (string, required) - Client Secret of Azure Service Principal
220220- ` num_partitions ` (int, optional, default: 1) - Number of partitions for reading data
221+ - ` inferSchema ` (bool, optional, default: true) - if we do the schema inference by sampling result.
221222
222223** KQL Query Examples:**
223224
Original file line number Diff line number Diff line change @@ -258,23 +258,19 @@ def schema(self):
258258 """Return the schema for reading data.
259259
260260 If the user doesn't provide a schema, this method infers it by executing
261- a sample query with limit 1.
261+ a sample query with limit 1. Only if inferSchema is true.
262262
263263 Returns:
264264 StructType: The schema of the data
265265
266266 """
267- # Check if we're being called for reading (workspace_id present)
268- # vs writing (dce present)
269- if self .options .get ("workspace_id" ):
270- # Reading - infer schema from query
267+
268+ infer_schema = self .options .get ("inferSchema" , "true" ).lower () == "true"
269+ if infer_schema :
271270 return self ._infer_read_schema ()
272271 else :
273- # Writing - schema will be provided by Spark
274- raise PySparkNotImplementedError (
275- errorClass = "NOT_IMPLEMENTED" ,
276- messageParameters = {"feature" : "schema for write operations" },
277- )
272+ raise Exception ("Must provide schema if inferSchema is false" )
273+
278274
279275 def _infer_read_schema (self ):
280276 """Infer schema by executing a sample query with limit 1.
You can’t perform that action at this time.
0 commit comments