我想将一个巨大的 pyspark 数据帧保存为 Hive 表。我怎样才能有效地做到这一点?我希望使用pyspark.sql.DataFrameWriter.saveAsTable中的saveAsTable(name, format=None, mode=None,partitionBy=None, **options)。
# Let's say I have my dataframe, my_df
# Am I able to do the following?
my_df.saveAsTable('my_table')
Run Code Online (Sandbox Code Playgroud)
我的问题是我可以使用哪些格式以及我可以在哪里找到这些信息?OrcSerDe 是一个选择吗?我仍在学习这一点。谢谢。
我使用 Gradle 6.9,这是我的 build.gradle 文件:
plugins {
id "groovy"
id "java"
}
group "com.matthiasdenu"
version "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/releases/'
}
}
ext {
jobDslVersion = "1.77"
jenkinsVersion = "2.252"
}
sourceSets {
jobs {
groovy {
srcDirs "jobs"
compileClasspath += main.compileClasspath
}
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
dependencies {
compile("org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"){
// https://github.com/sheehan/job-dsl-gradle-example/issues/87
exclude group: "org.jenkins-ci.ui", module: "bootstrap"
}
}
test {
useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误消息:
Execution failed for task ':compileTestGroovy'.
> Could not resolve …Run Code Online (Sandbox Code Playgroud) 我发现我想经常更新结构,然后将结果通过管道传递给另一个函数。更新结构的需要不断破坏我的管道。
我发现自己经常这样做:
my_struct = %{my_struct | my_field_in_struct: a_new_value} |> my_funct1
my_struct = %{my_struct | my_field_in_struct: a_new_value} |> my_funct2
my_struct = %{my_struct | my_field_in_struct: a_new_value} |> my_funct3
Run Code Online (Sandbox Code Playgroud)
我想做类似的事情:
my_struct
|> %{ | my_field_in_struct: a_new_value}
|> my_funct1
|> %{ | my_field_in_struct: a_new_value}
|> my_funct2
|> %{ | my_field_in_struct: a_new_value}
|> my_funct3
Run Code Online (Sandbox Code Playgroud)
原始语法可能没有那么糟糕,但仍然如此。
我知道我可以使用Map.put(),但是我必须在我的模块中编写一个函数来将结果映射转换回我的结构类型。
有没有人遇到过这种小烦恼?有没有干净的替代品?