gp数据库---子查询报错 correlated subquery with skip-level correlations is not supported

在使用Greenplum数据库时,通过JDBC执行SQL遇到子查询报错,问题在于子查询中存在跨级引用主表字段。解决方法是避免这种skip-level correlations,将复杂的子查询拆分为多个独立查询。示例展示了原SQL与修改后的SQL对比,修改后的SQL移除了内部子查询,成功在数据库和代码中执行。
摘要由CSDN通过智能技术生成

gp数据库(greenPlum)代码jdbc执行sql报错信息:

SQL state [0A000]; error code [0]; [Pivotal][Greenplum JDBC Driver][Greenplum]correlated subquery with skip-level correlations is not supported. ; nested exception is java.sql.SQLException: [Pivotal][Greenplum JDBC Driver][Greenplum]correlated subquery with skip-level correlations is not supported.

问题现象:
要查询原sql在库里可以执行,但是代码jdbc执行会报错。
sql如下:

select
    (select
        CASE
            WHEN type = '12'
            THEN (select a.area_id from dim.dim_area_relation a where a.utrancell_district_name=district_name)
            WHEN type = '13'
            THEN (select a.parent_area_id from dim.dim_area_relation a where a.utrancell_district_name=district_name)
            ELSE '其他'
        END DISTRICT_ID
    from  dim.dim_area_relation a
    wh
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Sure, here is an example Python code for Uplift model with low-rank regularization logistic regression for multiple correlated binary responses: ```python import numpy as np from sklearn.linear_model import LogisticRegression # define the Uplift model with low-rank regularization logistic regression class UpliftLowRankLogisticRegression: def __init__(self, rank=5, alpha=1.0): self.rank = rank self.alpha = alpha self.models = [] self.w = None def fit(self, X, y, t): # calculate the treatment and control groups X_treatment = X[t == 1] y_treatment = y[t == 1] X_control = X[t == 0] y_control = y[t == 0] # fit the logistic regression model for each response for i in range(y.shape[1]): model = LogisticRegression(penalty='l2', C=self.alpha) model.fit(np.hstack((X_treatment, y_treatment[:, i].reshape(-1, 1))), y_treatment[:, i]) self.models.append(model) # use SVD to learn the low-rank representation w U, S, Vt = np.linalg.svd(y_control - self.predict(X_control)) self.w = Vt[:self.rank].T def predict(self, X): # calculate the uplift score for each response uplift_scores = np.zeros((X.shape[0], len(self.models))) for i, model in enumerate(self.models): uplift_scores[:, i] = model.predict_proba(X)[:, 1] # calculate the predicted response for the control group y_control_pred = np.dot(X, self.w) # calculate the predicted response for the treatment group y_treatment_pred = y_control_pred + uplift_scores # return the predicted response matrix return np.vstack((y_control_pred, y_treatment_pred)) ``` The `UpliftLowRankLogisticRegression` class takes two hyperparameters: `rank` for the rank of the low-rank representation w and `alpha` for the regularization strength of logistic regression. In the `fit` method, the treatment and control groups are separated, and logistic regression models are fitted for each response using the treatment group. Then, SVD is used to learn the low-rank representation w from the predicted responses of the control group. In the `predict` method, the uplift scores for each response are calculated using the logistic regression models and added to the predicted responses of the control group to obtain the predicted responses of the treatment group. The predicted response matrix is returned by stacking the predicted responses of the control and treatment groups vertically.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值