diff options
author | hcpp <[email protected]> | 2023-02-03 11:33:19 +0300 |
---|---|---|
committer | hcpp <[email protected]> | 2023-02-03 11:33:19 +0300 |
commit | b80714b23581d4516388b3ec8d8f1b80ac0cfc69 (patch) | |
tree | cb23e165b1d66e9cd85ba70b1295fc7a6b1399ca | |
parent | 3d41ba9017aa2f2dd6b18e62ef496464da0d6263 (diff) |
unix timestamp has been removed from generator
-rw-r--r-- | ydb/library/yql/providers/s3/path_generator/ut/yql_generate_partitioning_rules_ut.cpp | 17 | ||||
-rw-r--r-- | ydb/library/yql/providers/s3/path_generator/yql_s3_path_generator.cpp | 10 |
2 files changed, 5 insertions, 22 deletions
diff --git a/ydb/library/yql/providers/s3/path_generator/ut/yql_generate_partitioning_rules_ut.cpp b/ydb/library/yql/providers/s3/path_generator/ut/yql_generate_partitioning_rules_ut.cpp index 854794233fa..b80adb3665e 100644 --- a/ydb/library/yql/providers/s3/path_generator/ut/yql_generate_partitioning_rules_ut.cpp +++ b/ydb/library/yql/providers/s3/path_generator/ut/yql_generate_partitioning_rules_ut.cpp @@ -162,8 +162,8 @@ Y_UNIT_TEST_SUITE(TGenerateTests) { UNIT_ASSERT_VALUES_EQUAL(rules[3].ColumnValues.size(), 2); } - Y_UNIT_TEST(SuccessGenerateDateWithUnixtime) { - auto generator = CreatePathGenerator(R"( + Y_UNIT_TEST(FailedGenerateDateWithUnixtime) { + UNIT_ASSERT_EXCEPTION_CONTAINS(CreatePathGenerator(R"( { "projection.enabled" : true, "projection.city.type" : "enum", @@ -176,14 +176,7 @@ Y_UNIT_TEST_SUITE(TGenerateTests) { "projection.code.unit" : "DAYS", "storage.location.template" : "//${city}/${code}//" } - )", {"city", "code"}); - - auto rules = generator->GetRules(); - UNIT_ASSERT_VALUES_EQUAL(rules.size(), 2); - UNIT_ASSERT_VALUES_EQUAL(rules[0].Path, "MSK/1970-01-03/"); - UNIT_ASSERT_VALUES_EQUAL(rules[0].ColumnValues.size(), 2); - UNIT_ASSERT_VALUES_EQUAL(rules[1].Path, "SPB/1970-01-03/"); - UNIT_ASSERT_VALUES_EQUAL(rules[1].ColumnValues.size(), 2); + )", {"city", "code"}), yexception, "error in datetime parsing. Input data: 201701"); } Y_UNIT_TEST(SuccessGenerateDateWithNow) { @@ -317,13 +310,13 @@ Y_UNIT_TEST_SUITE(TGenerateTests) { "projection.enabled" : "true", "storage.location.template" : "${year}", "projection.year.type" : "date", - "projection.year.min" : "1900", + "projection.year.min" : "1971-01-01", "projection.year.max" : "NOW", "projection.year.interval" : "1", "projection.year.format" : "%Y", "projection.year.unit" : "DAYS" } - )", {"year"}), yexception, "Location path 1970/ is composed by different projection value sets { ${year} = 1970-01-01 } and { ${year} = 1970-01-02 }");; + )", {"year"}), yexception, "Location path 1971/ is composed by different projection value sets { ${year} = 1971-01-01 } and { ${year} = 1971-01-02 }");; } } diff --git a/ydb/library/yql/providers/s3/path_generator/yql_s3_path_generator.cpp b/ydb/library/yql/providers/s3/path_generator/yql_s3_path_generator.cpp index c4969a2f3f1..7a293813b31 100644 --- a/ydb/library/yql/providers/s3/path_generator/yql_s3_path_generator.cpp +++ b/ydb/library/yql/providers/s3/path_generator/yql_s3_path_generator.cpp @@ -213,16 +213,6 @@ TInstant AddUnit(TInstant current, int64_t interval, IPathGenerator::EIntervalUn } TInstant ParseDate(const TString& dateStr, const TInstant& now) { - try { - size_t idx = 0; - int64_t unixTime = std::stoll(dateStr, &idx); - if (idx == dateStr.Size()) { - return TInstant::FromValue(unixTime * 1000 * 1000); - } - } catch (const std::exception&) { - // trying other options - } - const std::string pattern = "^\\s*(NOW)\\s*(([\\+\\-])\\s*([0-9]+)\\s*(YEARS?|MONTHS?|WEEKS?|DAYS?|HOURS?|MINUTES?|SECONDS?)\\s*)?$"; std::regex word_regex(pattern); auto wordBegin = std::sregex_iterator(dateStr.begin(), dateStr.end(), word_regex); |