Apache pig 如何使用pig实现1型和2型维度表
我需要通过使用PIG实现类型1和类型维度表来实现一个小型POC 类型1-覆盖旧值。在此方法中,数据库中不保留维度更改的历史记录。旧标注值将被新标注值覆盖。此类型易于维护,通常用于因处理更正(例如删除特殊字符、更正拼写错误)而导致更改的数据 更改前:Apache pig 如何使用pig实现1型和2型维度表,apache-pig,Apache Pig,我需要通过使用PIG实现类型1和类型维度表来实现一个小型POC 类型1-覆盖旧值。在此方法中,数据库中不保留维度更改的历史记录。旧标注值将被新标注值覆盖。此类型易于维护,通常用于因处理更正(例如删除特殊字符、更正拼写错误)而导致更改的数据 更改前: Customer_ID Customer_Name Customer_Type 1 Cust_1 Corporate Customer_ID Customer_Name Customer_Type 1 Cust_1 Retail
Customer_ID Customer_Name Customer_Type
1 Cust_1 Corporate
Customer_ID Customer_Name Customer_Type
1 Cust_1 Retail
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 31-12-9999 Y
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 17-05-2012 N
2 Cust_1 Retail 18-05-2012 31-12-9999 Y
更改后:
Customer_ID Customer_Name Customer_Type
1 Cust_1 Corporate
Customer_ID Customer_Name Customer_Type
1 Cust_1 Retail
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 31-12-9999 Y
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 17-05-2012 N
2 Cust_1 Retail 18-05-2012 31-12-9999 Y
类型2-创建新的附加记录。在这种方法中,所有维度更改的历史记录都保存在数据库中。通过向维度表添加具有新代理键的新行,可以捕获属性更改。前一行和新行都包含自然键(或其他持久标识符)作为属性。此方法中还使用了“生效日期”和“当前指标”列。当前指示器设置为“Y”的记录只能有一条。对于“生效日期”列,即开始日期和结束日期,当前记录的结束日期通常设置为值9999-12-31。在类型2中引入对维度模型的更改可能是非常昂贵的数据库操作,因此不建议在将来可能添加新属性的维度中使用它
更改前:
Customer_ID Customer_Name Customer_Type
1 Cust_1 Corporate
Customer_ID Customer_Name Customer_Type
1 Cust_1 Retail
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 31-12-9999 Y
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 17-05-2012 N
2 Cust_1 Retail 18-05-2012 31-12-9999 Y
更改后:
Customer_ID Customer_Name Customer_Type
1 Cust_1 Corporate
Customer_ID Customer_Name Customer_Type
1 Cust_1 Retail
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 31-12-9999 Y
Customer_ID Customer_Name Customer_Type Start_Date End_Date Current_Flag
1 Cust_1 Corporate 22-07-2010 17-05-2012 N
2 Cust_1 Retail 18-05-2012 31-12-9999 Y
因此,我们可以在这两个基础上实现一个小型POC
请帮忙 Pig不支持对现有数据进行重写,因此不能仅使用Pig来实现。但是,如果您在配置单元中创建了表,并使用将数据插入表中,将处理数据保留在Pig中,那么它应该可以正常工作。请提供帮助。我需要做一个POC。我们可以删除旧文件并再次加载新的更新文件吗?这是否符合type1的逻辑?