您好,我正在使用由 3 列(年、月和日)分区的 Hive 表。我有以下格式的数据。
/table1/year=2024/month=1/day=20/file1
/table1/year=2024/month=1/day=16/file1
/table1/year=2024/month=1/day=9/file1
需要帮助编写一个选择查询以动态获取最新年月日分区中的所有记录。
下面是带有硬编码值的查询,我需要对其进行动态查询。谢谢
从表 1 中选择 *,其中年 = 2024 年,月 = 1,日 = 20;
您可以使用 sysdate() 上的year()、month() 和day() 函数来计算这些列
Select * from table1 where year=year(current_timestamp()) and month = month(current_timestamp()) and day=day(current_timestamp());