@@ -912,8 +912,9 @@ func (s *SchemaCheckPass) convertQueryDateTimeFunctionToClickhouse(indexSchema s
912912 }
913913 return model .NewFunction ("toHour" , e .Args [0 ].Accept (b ).(model.Expr ))
914914
915- // TODO this is a place for over date/time related functions
916- // add more
915+ case model .FromUnixTimeFunction :
916+ args := b .VisitChildren (e .Args )
917+ return model .NewFunction ("fromUnixTimestamp64Milli" , args ... )
917918
918919 default :
919920 return visitFunction (b , e )
@@ -941,9 +942,9 @@ func (s *SchemaCheckPass) convertQueryDateTimeFunctionToDoris(indexSchema schema
941942 return e
942943 }
943944 return model .NewFunction ("HOUR" , e .Args [0 ].Accept (b ).(model.Expr ))
944-
945- // TODO this is a place for over date/time related functions
946- // add more
945+ case model . FromUnixTimeFunction :
946+ args := b . VisitChildren ( e . Args )
947+ return model . NewFunction ( "FROM_UNIXTIME" , args ... )
947948
948949 default :
949950 return visitFunction (b , e )
@@ -1083,7 +1084,7 @@ func (s *SchemaCheckPass) acceptIntsAsTimestamps(indexSchema schema.Schema, quer
10831084 }
10841085 }
10851086 if ok {
1086- if f , okF := model .ToFunction (expr ); okF && f .Name == "fromUnixTimestamp64Milli" && len (f .Args ) == 1 {
1087+ if f , okF := model .ToFunction (expr ); okF && f .Name == model . FromUnixTimeFunction && len (f .Args ) == 1 {
10871088 if l , okL := model .ToLiteral (f .Args [0 ]); okL {
10881089 if _ , exists := l .Format (); exists { // heuristics: it's a date <=> it has a format
10891090 return model .NewInfixExpr (col , e .Op , f .Args [0 ])
@@ -1105,7 +1106,7 @@ func (s *SchemaCheckPass) acceptIntsAsTimestamps(indexSchema schema.Schema, quer
11051106 if f .Name == "toTimezone" && len (f .Args ) == 2 {
11061107 if col , ok := model .ExtractColRef (f .Args [0 ]); ok && table .IsInt (col .ColumnName ) {
11071108 // adds fromUnixTimestamp64Milli
1108- return model .NewFunction ("toTimezone" , model .NewFunction ("fromUnixTimestamp64Milli" , f .Args [0 ]), f .Args [1 ])
1109+ return model .NewFunction ("toTimezone" , model .NewFunction (model . FromUnixTimeFunction , f .Args [0 ]), f .Args [1 ])
11091110 }
11101111 }
11111112 return visitFunction (b , f )
0 commit comments