Skip to content

Commit

Permalink
Fix format IT
Browse files Browse the repository at this point in the history
  • Loading branch information
FearfulTomcat27 authored Jan 22, 2025
1 parent 765cbb2 commit ddd580d
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.apache.iotdb.relational.it.query.old.builtinfunction.scalar;

import org.apache.iotdb.db.utils.DateTimeUtils;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
Expand All @@ -22,24 +23,27 @@

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import java.sql.Connection;
import java.sql.Statement;
import java.time.LocalDate;
import java.time.ZoneId;

import static java.lang.String.format;
import static org.apache.iotdb.db.it.utils.TestUtils.tableAssertTestFail;
import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;

@Ignore
@RunWith(IoTDBTestRunner.class)
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
public class IoTDBFormatFunctionTableIT {

private static final String DATABASE_NAME = "db";

private static final ZoneId zoneId = ZoneId.of("Z");

private static final String[] SQLs =
new String[] {
// normal cases
Expand Down Expand Up @@ -152,7 +156,10 @@ public void testTimestampFormat() {
tableResultSetEqualTest(
"SELECT FORMAT('%tc', s1) FROM timestamp_table",
new String[] {"_col0"},
new String[] {"周四 1月 01 00:00:00 Z 1970,", "周四 1月 01 00:00:00 Z 1970,"},
new String[] {
format("%tc,", DateTimeUtils.convertToZonedDateTime(10, zoneId)),
format("%tc,", DateTimeUtils.convertToZonedDateTime(20, zoneId)),
},
DATABASE_NAME);
}

Expand All @@ -161,7 +168,10 @@ public void testDateFormat() {
tableResultSetEqualTest(
"SELECT FORMAT('%1$tA, %1$tB %1$te, %1$tY', s1) FROM date_table",
new String[] {"_col0"},
new String[] {"星期一, 一月 1, 2024,", "星期二, 七月 4, 2006,"},
new String[] {
format("%1$tA, %1$tB %1$te, %1$tY,", LocalDate.of(2024, 1, 1)),
format("%1$tA, %1$tB %1$te, %1$tY,", LocalDate.of(2006, 7, 4))
},
DATABASE_NAME);

tableResultSetEqualTest(
Expand Down

0 comments on commit ddd580d

Please sign in to comment.