diff --git a/flyteadmin/pkg/manager/impl/execution_manager.go b/flyteadmin/pkg/manager/impl/execution_manager.go index b15dd36ff4..76242b1e4d 100644 --- a/flyteadmin/pkg/manager/impl/execution_manager.go +++ b/flyteadmin/pkg/manager/impl/execution_manager.go @@ -750,11 +750,15 @@ func (m *ExecutionManager) getStringFromInput(ctx context.Context, inputBinding p := inputVal.GetScalar().GetPrimitive() switch p.GetValue().(type) { case *core.Primitive_Integer: - strVal = p.GetStringValue() + strVal = fmt.Sprintf("%d", p.GetInteger()) case *core.Primitive_Datetime: t := time.Unix(p.GetDatetime().Seconds, int64(p.GetDatetime().Nanos)) t = t.In(time.UTC) - strVal = t.Format("2006-01-02") + if t.Hour() == 0 && t.Minute() == 0 && t.Second() == 0 { + strVal = t.Format("2006-01-02") + } else { + strVal = t.Format("2006-01-02T15:04:05Z07:00") + } case *core.Primitive_StringValue: strVal = p.GetStringValue() case *core.Primitive_FloatValue: diff --git a/flyteadmin/pkg/manager/impl/execution_manager_test.go b/flyteadmin/pkg/manager/impl/execution_manager_test.go index 4ee3fce58a..4ad5a19dbc 100644 --- a/flyteadmin/pkg/manager/impl/execution_manager_test.go +++ b/flyteadmin/pkg/manager/impl/execution_manager_test.go @@ -6035,3 +6035,45 @@ func TestQueryTemplate(t *testing.T) { assert.Error(t, err) }) } + +func TestLiteralParsing(t *testing.T) { + ctx := context.Background() + + aDate := time.Date( + 2063, 4, 5, 00, 00, 00, 0, time.UTC) + aTime := time.Date( + 2063, 4, 5, 15, 42, 00, 0, time.UTC) + + rawInputs := map[string]interface{}{ + "aStr": "hello world", + "anInt": 1, + "aFloat": 6.62607015e-34, + "aDate": aDate, + "aTime": aTime, + "aBool": true, + } + + otherInputs, err := coreutils.MakeLiteralMap(rawInputs) + assert.NoError(t, err) + + m := ExecutionManager{} + testCases := []struct { + varName string + expectedString string + }{ + {"aStr", "hello world"}, + {"anInt", "1"}, + {"aFloat", "0.00"}, + {"aDate", "2063-04-05"}, + {"aTime", "2063-04-05T15:42:00Z"}, + {"aBool", "true"}, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("Parse %s", tc.varName), func(t *testing.T) { + binding := core.InputBindingData{Var: tc.varName} + strVal, err := m.getStringFromInput(ctx, binding, otherInputs.Literals) + assert.NoError(t, err) + assert.Equal(t, tc.expectedString, strVal) + }) + } +}