Skip to content

Commit f611fa4

Browse files
dcherednikadameat
authored andcommitted
Fix json float/double print format (ydb-platform#7572)
SELECT CAST("311111111113.222222223" as Double) should not lost precision
1 parent 69dc2e6 commit f611fa4

File tree

1 file changed

+1
-86
lines changed

1 file changed

+1
-86
lines changed

ydb/core/viewer/viewer_ut.cpp

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,91 +1589,6 @@ Y_UNIT_TEST_SUITE(Viewer) {
15891589
size_t AuthorizeTicketFails = 0;
15901590
};
15911591

1592-
TString PostQuery(TKeepAliveHttpClient& httpClient, TString query, TString action = "", TString transactionMode = "") {
1593-
TStringStream requestBody;
1594-
requestBody
1595-
<< "{ \"query\": \"" << query << "\","
1596-
<< " \"database\": \"/Root\","
1597-
<< " \"action\": \"" << action << "\","
1598-
<< " \"syntax\": \"yql_v1\","
1599-
<< " \"transaction_mode\": \"" << transactionMode << "\","
1600-
<< " \"stats\": \"none\" }";
1601-
TStringStream responseStream;
1602-
TKeepAliveHttpClient::THeaders headers;
1603-
headers["Content-Type"] = "application/json";
1604-
headers["Authorization"] = "test_ydb_token";
1605-
const TKeepAliveHttpClient::THttpCode statusCode = httpClient.DoPost("/viewer/query?timeout=600000&base64=false&schema=modern", requestBody.Str(), &responseStream, headers);
1606-
const TString response = responseStream.ReadAll();
1607-
UNIT_ASSERT_EQUAL_C(statusCode, HTTP_OK, statusCode << ": " << response);
1608-
return response;
1609-
}
1610-
1611-
Y_UNIT_TEST(ExecuteQueryDoesntExecuteSchemeOperationsInsideTransation) {
1612-
TPortManager tp;
1613-
ui16 port = tp.GetPort(2134);
1614-
ui16 grpcPort = tp.GetPort(2135);
1615-
ui16 monPort = tp.GetPort(8765);
1616-
auto settings = TServerSettings(port);
1617-
settings.InitKikimrRunConfig()
1618-
.SetNodeCount(1)
1619-
.SetUseRealThreads(true)
1620-
.SetDomainName("Root")
1621-
.SetMonitoringPortOffset(monPort, true);
1622-
1623-
TServer server(settings);
1624-
server.EnableGRpc(grpcPort);
1625-
TClient client(settings);
1626-
client.InitRootScheme();
1627-
1628-
TTestActorRuntime& runtime = *server.GetRuntime();
1629-
runtime.SetLogPriority(NKikimrServices::TICKET_PARSER, NLog::PRI_TRACE);
1630-
1631-
TKeepAliveHttpClient httpClient("localhost", monPort);
1632-
1633-
//Scheme operations cannot be executed inside transaction
1634-
TString response = PostQuery(httpClient, "CREATE TABLE `/Root/Test` (Key Uint64, Value String, PRIMARY KEY (Key));", "execute-query", "serializable-read-write");
1635-
{
1636-
NJson::TJsonReaderConfig jsonCfg;
1637-
NJson::TJsonValue json;
1638-
NJson::ReadJsonTree(response, &jsonCfg, &json, /* throwOnError = */ true);
1639-
UNIT_ASSERT_EQUAL_C(json["status"].GetString(), "PRECONDITION_FAILED", response);
1640-
}
1641-
}
1642-
1643-
Y_UNIT_TEST(UseTransactionWhenExecuteDataActionQuery) {
1644-
TPortManager tp;
1645-
ui16 port = tp.GetPort(2134);
1646-
ui16 grpcPort = tp.GetPort(2135);
1647-
ui16 monPort = tp.GetPort(8765);
1648-
auto settings = TServerSettings(port);
1649-
settings.InitKikimrRunConfig()
1650-
.SetNodeCount(1)
1651-
.SetUseRealThreads(true)
1652-
.SetDomainName("Root")
1653-
.SetMonitoringPortOffset(monPort, true);
1654-
1655-
TServer server(settings);
1656-
server.EnableGRpc(grpcPort);
1657-
TClient client(settings);
1658-
client.InitRootScheme();
1659-
1660-
TTestActorRuntime& runtime = *server.GetRuntime();
1661-
runtime.SetLogPriority(NKikimrServices::TICKET_PARSER, NLog::PRI_TRACE);
1662-
1663-
TKeepAliveHttpClient httpClient("localhost", monPort);
1664-
1665-
PostQuery(httpClient, "CREATE TABLE `/Root/Test` (Key Uint64, Value String, PRIMARY KEY (Key));", "execute-query");
1666-
PostQuery(httpClient, "INSERT INTO `/Root/Test` (Key, Value) VALUES (1, 'testvalue');", "execute-query");
1667-
TString response = PostQuery(httpClient, "SELECT * FROM `/Root/Test`;", "execute-data");
1668-
{
1669-
NJson::TJsonReaderConfig jsonCfg;
1670-
NJson::TJsonValue json;
1671-
NJson::ReadJsonTree(response, &jsonCfg, &json, /* throwOnError = */ true);
1672-
auto resultSets = json["result"].GetArray();
1673-
UNIT_ASSERT_EQUAL_C(1, resultSets.size(), response);
1674-
}
1675-
}
1676-
16771592
Y_UNIT_TEST(FloatPointJsonQuery) {
16781593
TPortManager tp;
16791594
ui16 port = tp.GetPort(2134);
@@ -1704,7 +1619,7 @@ Y_UNIT_TEST_SUITE(Viewer) {
17041619
"database": "/Root",
17051620
"action": "execute-script",
17061621
"syntax": "yql_v1",
1707-
"stats": "none"
1622+
"stats": "profile"
17081623
})json";
17091624
const TKeepAliveHttpClient::THttpCode statusCode = httpClient.DoPost("/viewer/query?timeout=600000&base64=false&schema=modern", requestBody, &responseStream, headers);
17101625
const TString response = responseStream.ReadAll();

0 commit comments

Comments
 (0)