【发布时间】:2019-07-11 20:34:03
【问题描述】:
我正在尝试在 Hive 中编写等效于 SQL 的存储过程。我设法翻译了前两个:
DECLARE @ReloadMonths as INT=15
set reloadMonths=15
DECLARE @Anchor_DT as DATE =EOMONTH(Getdate(),-1);
set anchor_dt=select last_day(FROM_UNIXTIME(UNIX_TIMESTAMP(),'yyyy-MM-dd')`)
但我在翻译以下两个时遇到了麻烦:
DECLARE @YearMonth as INT=C_II.Common.FN_COM_DATEToYearMonth(@Anchor_DT);
set yearMonth=(anchor_dt,'yyyy-MM')
DECLARE @StartYearMonth as INT =ISNULL(@StartYearMonth_Inp,C_II.Common.FN_COM_DATEToYearMonth(DATEADD(MM,-@ReloadMonths+1,@Anchor_DT)));
set startYearMonth=${hiveconf:${hiveconf:startYearMonth}};
有什么想法或建议吗?
【问题讨论】:
-
能否请您更详细地描述您的要求,并在问题中添加更多关于期望的详细信息。谢谢
-
C_II.Common.FN_COM_DATEToYearMonth 这看起来像是特定于您的项目的一些用户功能。你能解释一下它的作用吗?
-
您还计算了 yearMonth 并且没有在以后的语句中使用它。您在最终变量 startYearMonth 中期望哪个日期或值?是2018-04-30吗??请确认。
-
我希望我能够满足要求。 :-)
标签: python-3.x hive pyspark hiveql