如何解决如何让 Great_Expectations 在 Apache Spark ValueError: Unrecognized spark type: string 中使用 Spark Dataframes
我有一个 Apache Spark 数据框,它是一个“字符串”类型的字段。但是,Great_Expectations 无法识别字段类型。我已经导入了我认为必要的模块,但不确定为什么 Great_Expectations 无法识别该字段
import great_expectations as ge
import great_expectations.dataset.sparkdf_dataset
from great_expectations.dataset.sparkdf_dataset import SparkDFDataset
from pyspark.sql.types import StructType,StructField,IntegerType,StringType,BooleanType
以下代码将 csv 作为数据帧读取
test = spark.read.csv('abfss://root@adlspretbiukadlsdev.dfs.core.windows.net/RAW/LANDING/customers.csv',inferSchema=True,header=True)
以下显示了架构:
test.printSchema()
Command executed in 2 sec 64 ms by carlton on 1:53:28 PM,6/17/21
root
|-- first_name: string (nullable = true)
我认为下面这行代码从上面的 Spark 数据帧创建了 Great_Expectation 数据帧
test2 = ge.dataset.SparkDFDataset(test)
然后我按照以下期望编码:
test2.expect_column_values_to_be_of_type(column='first_name',type_='string')
但是,我收到以下错误:
ValueError: Unrecognized spark type: string
Traceback (most recent call last):
File "/home/trusted-service-user/cluster-env/env/lib/python3.6/site-packages/great_expectations/data_asset/util.py",line 80,in f
return self.mthd(obj,*args,**kwargs)
不知道为什么 Great_Expectations 无法识别 Spark 类型?
解决方法
您需要使用 Imports System.Threading
Public Class Form1
Dim proc As New System.Diagnostics.Process()
Public Function IsSingleInstance() As Boolean
Try
Mutex.OpenExisting("Mutex")
Catch
mutexx = New Mutex(True,"Mutex")
Return True
End Try
Return False
End Function
Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click
proc = Process.Start("notepad.exe")
proc.WaitForInputIdle()
Me.Activate()
If Not IsSingleInstance() Then
MsgBox("There are more instance!")
proc.CloseMainWindow()
Else
IsSingleInstance()
End If
End Sub
End Class
、StringType
等名称 - 与 documentation 中指定的名称相同。应该是这样的:
LongType
看截图:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。