蜂巢-在联接表上使用侧面爆炸(split())

时间:2019-07-29 14:25:43

标签: sql hive split

我想在更复杂的示例中使用this简单主题。这是我的尝试:

auth.createUserWithEmailAndPassword(email, password)
    .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
                // Sign in success, update UI with the signed-in user's information
                Log.d(TAG, "createUserWithEmail:success");
                FirebaseUser user = mAuth.getCurrentUser();
                updateUI(user);
            } else {
                // If sign in fails, display a message to the user.
                Log.w(TAG, "createUserWithEmail:failure", task.getException());
                Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
                        Toast.LENGTH_SHORT).show();
                updateUI(null);
            }
            // ...
        }
    });

我想在使用多个联接创建的表上应用拆分功能。

但是我继续遇到此错误:

SELECT maxxx.COD_ENTREP as ID_ENTITE,
    maxxx.COD_ENTREP_ASSU as ID_ENTITE_GARANTE,
    maxxx.ID_NOTIFICATION as ID_NOTIFICATION,
    maxxx.OBJET_METIER as OBJET_METIER,
    REF_EXT_OBJET_METIER,
    case when maxxx.typ_mvt="S" then 1 else 0 end AS TOP_SUPP,
    case when maxxx.typ_mvt = "S" then to_date(substr(maxxx.dt_capt, 1, 11)) else null end AS DT_SUPP,
    minnn.typ_mvt as MIN_MVT,
    maxxx.typ_mvt as MAX_MVT,
    case when minnn.typ_mvt = 'C' then 'C' else 'M' end as TYP_MVT

FROM 

(select s.id_notification, s.dt_capt, s.typ_mvt from ${use_database}.pz_send_notification as s
join
(select id_notification, min(dt_capt) as dtmin from ${use_database}.pz_send_notification group by id_notification) as minn
on s.id_notification=minn.id_notification and s.dt_capt=minn.dtmin) as minnn

join

(select s.id_notification, s.dt_capt, s.typ_mvt, s.cod_entrep, s.cod_entrep_assu, s.objet_metier from ${use_database}.pz_send_notification as s
join
(select id_notification, max(dt_capt) as dtmax from ${use_database}.pz_send_notification group by id_notification) as maxx
on s.id_notification=maxx.id_notification and s.dt_capt=maxx.dtmax) as maxxx

on minnn.id_notification=maxxx.id_notification 

lateral view explode(split(maxxx.OBJET_METIER, ";")) maxxx.OBJET_METIER as ee;

编辑

这是查询的结果没有最后一行(侧面视图爆炸)

enter image description here

我想要的是一张有4行的表格。前三个是使用“;”上的split复制ref_ext_objet_metier_column的结果。

1 个答案:

答案 0 :(得分:2)

分号在Hive中具有特殊含义,应屏蔽。在Hive中使用双斜杠:

Console.WriteLine("Enter a new string:");
string newString = Console.ReadLine();

string[] beforeArray = { "a", "b", "d", "f", "m", "A", "B", "D", "F", "M" };    
string[] afterArray = { "!" };

Console.WriteLine(newString);

别名也错误。为侧面视图提供正确的别名,如下所示:

split(maxxx.OBJET_METIER, '\\;')

例如,在查询中以lateral view explode(split(maxxx.OBJET_METIER, '\\;')) om as splitted_col 进行寻址。

如果您使用的是直线,但om.splitted_col不起作用,请尝试'\\;'

'\073'