Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zclllyybb committed Jul 12, 2024
1 parent 6af768a commit d93a06c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void removeDuplicateTables() {
@Override
protected void runAfterCatalogReady() {
PropertySchema.DateProperty prop =
new PropertySchema.DateProperty("key", TimeUtils.DATETIME_FORMAT);
new PropertySchema.DateProperty("key", TimeUtils.getDatetimeFormatWithTimeZone());
// list iceberg tables in dbs
// When listing table is done, remove database from icebergDbs.
for (Iterator<Map.Entry<Long, Database>> it = icebergDbs.entrySet().iterator(); it.hasNext(); it.remove()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ private static JobSchedule genJobSchedule(MaterializedView materializedView) {
MVRefreshIntervalTriggerInfo info = materializedView.getRefreshInfo().getTriggerInfo().getIntervalTrigger();
long startTime;
try {
LocalDateTime dateTime = LocalDateTime.parse(info.getStartTime(), TimeUtils.DATETIME_FORMAT);
startTime = dateTime.toEpochSecond(TimeUtils.TIME_ZONE.getRules().getOffset(dateTime));
LocalDateTime dateTime = LocalDateTime.parse(info.getStartTime(),
TimeUtils.getDatetimeFormatWithTimeZone());
startTime = dateTime.toEpochSecond(TimeUtils.getDorisZoneId().getRules().getOffset(dateTime));
} catch (DateTimeParseException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public TPipelineFragmentParams planForPipeline(TUniqueId loadId, int fragmentIns

pipParams.setQueryOptions(queryOptions);
TQueryGlobals queryGlobals = new TQueryGlobals();
queryGlobals.setNowString(TimeUtils.DATETIME_FORMAT.format(LocalDateTime.now()));
queryGlobals.setNowString(TimeUtils.getDatetimeFormatWithTimeZone().format(LocalDateTime.now()));
queryGlobals.setTimestampMs(System.currentTimeMillis());
queryGlobals.setTimeZone(taskInfo.getTimezone());
queryGlobals.setLoadZeroTolerance(taskInfo.getMaxFilterRatio() <= 0.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.doris.mysql.privilege.AccessControllerManager;
import org.apache.doris.mysql.privilege.Auth;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.VariableMgr;

import com.google.common.collect.Lists;
import mockit.Expectations;
Expand All @@ -47,6 +48,13 @@ public class GrantStmtTest {

@Before
public void setUp() {
new Expectations() {
{
ctx.getSessionVariable();
minTimes = 0;
result = VariableMgr.newSessionVariable();
}
};
analyzer = AccessTestUtil.fetchAdminAnalyzer(true);
Auth auth = new Auth();
AccessControllerManager accessManager = new AccessControllerManager(auth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public void testNormal() {
Assert.assertNotNull(TimeUtils.getCurrentFormatTime());
Assert.assertNotNull(TimeUtils.getStartTimeMs());
Assert.assertTrue(TimeUtils.getElapsedTimeMs(0L) > 0);

Assert.assertEquals(-62135625600000L, TimeUtils.MIN_DATE.getTime());
Assert.assertEquals(253402185600000L, TimeUtils.MAX_DATE.getTime());
Assert.assertEquals(-62135625600000L, TimeUtils.MIN_DATETIME.getTime());
Assert.assertEquals(253402271999000L, TimeUtils.MAX_DATETIME.getTime());
}

@Test
Expand Down Expand Up @@ -148,7 +143,7 @@ public void testDateParse() {

@Test
public void testDateTrans() throws AnalysisException {
Assert.assertEquals(FeConstants.null_string, TimeUtils.longToTimeString(-2));
Assert.assertEquals(FeConstants.null_string, TimeUtils.longToTimeString((long) -2));

long timestamp = 1426125600000L;
Assert.assertEquals("2015-03-12 10:00:00", TimeUtils.longToTimeString(timestamp));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,19 @@
import org.apache.doris.nereids.types.IntegerType;
import org.apache.doris.nereids.util.PlanConstructor;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.VariableMgr;
import org.apache.doris.statistics.ColumnStatistic;
import org.apache.doris.statistics.ColumnStatisticBuilder;
import org.apache.doris.statistics.Statistics;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -61,6 +64,8 @@
import java.util.Optional;

public class StatsCalculatorTest {
@Mocked
private ConnectContext connectContext;

private Group newGroup() {
GroupExpression groupExpression = new GroupExpression(new FakePlan());
Expand All @@ -69,6 +74,21 @@ private Group newGroup() {
return group;
}

@Before
public void setUp() {
new Expectations() {
{
ConnectContext.get();
minTimes = 0;
result = connectContext;

connectContext.getSessionVariable();
minTimes = 0;
result = VariableMgr.newSessionVariable();
}
};
}

// TODO: temporary disable this test, until we could get column stats
// @Test
// public void testAgg() {
Expand Down

0 comments on commit d93a06c

Please sign in to comment.