火花:3.0.0
斯卡拉:2.12.8
我的数据框有一个包含 JSON 字符串的列,我想使用 StructType 从它创建一个新列。
临时 json 字符串 |
---|
{“名称”:“测试”,“id”:“12”,“类别”:[{“产品”:[“A”,“B”],“displayName”:“test_1”,“displayLabel”:“ test1"},{"products":["C"],"displayName":"test_2","displayLabel":"test2"}],"createdAt":"","createdBy":""} |
root
|-- temp_json_string: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
格式化 JSON:
{
"name":"test",
"id":"12",
"category":[
{
"products":[
"A",
"B"
],
"displayName":"test_1",
"displayLabel":"test1"
},
{
"products":[
"C"
],
"displayName":"test_2",
"displayLabel":"test2"
}
],
"createdAt":"",
"createdBy":""
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个 Struct 类型的新列,所以我尝试了:
dataFrame
.withColumn("temp_json_struct", struct(col("temp_json_string")))
.select("temp_json_struct")
Run Code Online (Sandbox Code Playgroud)
现在,我得到的架构为:
dataFrame
.withColumn("temp_json_struct", struct(col("temp_json_string")))
.select("temp_json_struct")
Run Code Online (Sandbox Code Playgroud)
期望的结果:
root
|-- temp_json_struct: struct (nullable = false)
| |-- temp_json_string: string (nullable = true)
Run Code Online (Sandbox Code Playgroud) 我一直在使用Java Spring框架来开发微服务。最近,我开始探索 NestJS,并有一个关于构建响应 DTO 的问题。
在Spring中,控制器是轻量级的,它们将调用交给服务层。
服务层实现业务逻辑,最后,它们调用负责构建响应 DTO 的 Mapper 类。映射器类可能就像将实体克隆到 DTO 一样简单,也可能使用多个数据库实体对象构建复杂的对象。
在NestJS中,大多数例子中class-transformer
都在使用。但我不确定这class-transformer
是否足以构建复杂的对象。对我来说class-transformer
基本上就是克隆对象。在 Spring 中相当于
BeanUtils.copyProperties(workingWellCompositeMemberContactTrace, workingWellDailyMemberAggEntity);
Run Code Online (Sandbox Code Playgroud)
所以我的问题是在 NestJS 中,哪一层负责构建复杂的响应对象?将实体对象发送到控制器是一个好的做法吗?
我正在使用Spring-Boot,Spring Rest Controller和Spring Data JPA.如果我没有指定@Transaction,那么也记录get的创建,但我想了解它是如何发生的.我的理解是Spring默认添加一个带有默认参数的事务但不确定它添加的位置是添加Service层还是存储库.
public interface CustomerRepository extends CrudRepository<Customer, Long> {
List<Customer> findByLastName(String lastName);
}
@Service
public class CustomerServiceImpl implements CustomerService> {
List<Customer> findByLastName(String lastName){
//read operation
}
// What will happen if @Transaction is missing. How record get's created without the annotation
public Customer insert(Customer customer){
// insert operations
}
}
Run Code Online (Sandbox Code Playgroud) 我们正在构建一个带有 Web(角度)门户(用于管理目的)的 iOS/Android 应用程序。后端 API 将使用 Java 构建,考虑到 Web 门户可能有不同类型的用户,我正在考虑使用 Spring 安全性。
我正在考虑使用我的后端服务使用 AWS Cognito 对用户进行身份验证。我不想将 iOS/Andorid/Web 直接与 AWS Cognito 集成,因为将来我们可能需要切换到其他提供商。
我不确定这是否可行,但正在考虑这样的事情: 1. 注册 API:iOS/Android/Web(带角色)使用电子邮件和密码调用我的后端服务。后端服务向 AWS Cognito 注册用户。AWS Cognito 将返回该用户的标识符以及我将在本地数据库中使用的相同标识符来创建链接黑白用户以及角色和其他表。后端服务将向客户端(iOS/Android 和 Web)返回一个 json 响应,说明用户已创建。
登录 API:iOS/Android/Web(带角色)使用电子邮件和密码调用我的后端服务。后端服务将电子邮件和密码传递给 AWS Cognito。如果用户可用,AWS Coginto 会返回一个令牌(带有到期时间),该令牌通过后端服务传递给客户端(iOS/Andorid/Web),如果不可用,则会引发异常。
获取用户信息 API:用户登录后,iOS/Android/Web(带角色)使用令牌(从登录 API 获取)调用我的后端服务。后端服务使用 AWS Cognito 验证令牌。如果令牌有效,AWS Cognito 还会返回用户信息,例如电子邮件和标识符,以在我的本地数据库中识别用户。
任何其他 API:所有其他后端都用作获取用户信息,即客户端 (iOS/Andorid/Web) 使用令牌调用后端服务,支持的服务使用相同的令牌使用 AWS Cognito 对用户进行身份验证。
注销 API。调用此 API 后,令牌应失效。
我已经阅读了很多 AWS Cognito 的文档,但读的越多,我就越困惑。如果有人可以让我知道上述是否可以通过 AWS Cognito 实现,如果可以,我该如何继续,这将是一个很大的帮助。
提前致谢!!
java spring-security amazon-web-services aws-sdk aws-cognito
要求:在插入/更新到特定表时,创建一个数据流并将其推送到弹性搜索。
以为 AWS RDS(MariaDb)----- 插入/更新以说出用户表 ---> AWS Kinesis流-使用AWS Lambda- > AWS ES
问题如何在插入/更新到特定表时创建运动学流?我可以通过AWS Lambda吗?
java elasticsearch amazon-kinesis aws-lambda amazon-kinesis-firehose
当尝试将 feign-httpclient 与 Spring-cloud-starter-openfeign 一起使用时,我收到 SSL 握手异常,而如果我不使用 feign-httpclient,相同的代码也可以工作。
我需要使用 feign-httpclient 因为我想使用连接工厂。
构建.gradle
//on commenting the below dependency the code works fine.
compile('io.github.openfeign:feign-httpclient:9.4.0')
compile('org.springframework.cloud:spring-cloud-starter-openfeign')
Run Code Online (Sandbox Code Playgroud)
假客户端
@FeignClient(name = "testClient", url = "https://test:9820")
public interface TestClient {
@RequestMapping(method = RequestMethod.POST, value = "/test", consumes = "application/json", produces = "application/json")
TesteDto get(TestRequestDto testRequestDto);
}
Run Code Online (Sandbox Code Playgroud)
调用代码:
testClient.get(new TestRequestDto("test"));
Run Code Online (Sandbox Code Playgroud)
应用程序.yml
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
loggerLevel: full
httpclient:
maxConnections: 200
maxConnectionsPerRoute: 200
enabled: true
Run Code Online (Sandbox Code Playgroud)
例外:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable …
Run Code Online (Sandbox Code Playgroud) 我正在尝试本地 Kubernetes(Docker-on-mac),并尝试提交 Spark 作业。Spark 作业连接 PostgreSQL 数据库并执行一些计算。
PostgreSQL 正在我的 Kube 上运行,由于我已经发布了它,我可以通过 localhost:5432 从主机访问它。但是,当 Spark 应用程序尝试连接到 PostgreSQL 时,它会抛出异常
Exception in thread "main" org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Run Code Online (Sandbox Code Playgroud)
kubectl 集群信息
Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Run Code Online (Sandbox Code Playgroud)
kubectl 获取服务 postgresql-published
kubectl描述服务spark-store-1588217023181-driver-svc
Name: spark-store-1588217023181-driver-svc
Namespace: default
Labels: <none>
Annotations: <none>
Selector: spark-app-selector=spark-533ecb8556b6439eb938d487cc77c330,spark-role=driver
Type: ClusterIP
IP: None
Port: driver-rpc-port 7078/TCP
TargetPort: 7078/TCP
Endpoints: <none> …
Run Code Online (Sandbox Code Playgroud) 我正在使用 RDS MariaDB,并且需要一个可以用于分析的从属数据库。我正在寻找 AWS 只读副本,但问题是它没有为我提供跳过包含一些敏感信息的少数表和列的复制的规定,我们不希望从数据库包含这些信息。
我可以使用 AWS 只读副本跳过少数表和列的复制吗?或者在 AWS 只读副本中,我可以编写可以从副本数据库中删除此信息的 AWS Lambda 吗?
我有一个 PostgreSQL 数据库表,内容如下:
id | person_key | age | gender | email
1 | 1 | 25 | M | test@mail.com
2 | 1 | 25 | M | test_2@gmail.com
3 | 2 | 35 | F | sample_2@gmail.com
4 | 1 | 25 | M | test_3@gmail.com
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种获取 json 输出的方法,如下所示:
person_key. | json
1 | {'age':25, 'gender':'M', 'email':['test@mail.com','test_2@gmail.com','test_3@gmail.com' ]}
2 | {'age':35, 'gender':'F', 'email':['sample_2@gmail.com' ]}
Run Code Online (Sandbox Code Playgroud) java ×5
aws-lambda ×2
spring ×2
amazon-rds ×1
apache-spark ×1
arrays ×1
aws-cognito ×1
aws-sdk ×1
database ×1
docker ×1
httpclient ×1
javascript ×1
jpa ×1
json ×1
kubectl ×1
kubernetes ×1
mariadb ×1
nestjs ×1
node.js ×1
postgresql ×1
scala ×1
schema ×1
spring-boot ×1
spring-mvc ×1
spring-rest ×1
sql ×1
struct ×1
transactions ×1
typeorm ×1