我正在尝试在Scala中更改DataFrame列的名称。我可以轻松更改直接字段的列名,但在转换数组结构列时遇到困难。
以下是我的DataFrame模式。
|-- _VkjLmnVop: string (nullable = true)
|-- _KaTasLop: string (nullable = true)
|-- AbcDef: struct (nullable = true)
| |-- UvwXyz: struct (nullable = true)
| | |-- _MnoPqrstUv: string (nullable = true)
| | |-- _ManDevyIxyz: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
但我需要如下所示的架构
|-- vkj_lmn_vop: string (nullable = true)
|-- ka_tas_lop: string (nullable = true)
|-- abc_def: struct (nullable = true)
| |-- uvw_xyz: struct (nullable = true)
| | |-- mno_pqrst_uv: string (nullable = true)
| | |-- …Run Code Online (Sandbox Code Playgroud) 此处使用 Scala 的示例:
我有一个班级和一个表达式,
class A{
if (1==3) 45 else 90
}
Run Code Online (Sandbox Code Playgroud)
何时在类中使用这种类型的表达式。(是不是像 Flow、Streams ……)
在一个演示项目中,https://github.com/chbatey/akka-http-typed存在以下代码,它可以编译但我不明白表达式“Http()(untypedSystem).bindAndHandle(routes .userRoutes, "localhost", 8080)" 可以编译,因为 bindAndHandle 方法接受下面的参数(所以第一个应该是 Flow,但它是一个 Route,即 RequestContext ? Future[RouteResult] 函数类型)。
在另一个项目中,我得到了编译错误,我可以理解,因为实际参数的类型为Route,但第一个参数的声明类型为Flow。
请指教。
//def bindAndHandle(
// handler: Flow[HttpRequest, HttpResponse, Any],
// interface: String, port: Int = DefaultPortForProtocol,
// connectionContext: ConnectionContext = defaultServerHttpContext,
val serverBinding: Future[Http.ServerBinding] = Http()(untypedSystem).bindAndHandle(routes.userRoutes, "localhost", 8080)
//type of routes.userRoutes is Route
//where type Route = RequestContext ? Future[RouteResult]
//how can it be that this compiles? In another project it does not (which makes more sense to me)
Run Code Online (Sandbox Code Playgroud)