You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2026-10-23 21:49:05 +03:00
37 lines
977 B
C++
37 lines
977 B
C++
// Include Glaze first to avoid specialization-after-instantiation
|
|
#include <glaze/glaze.hpp>
|
|
#include <string_view>
|
|
|
|
#include "functor_json.h"
|
|
#include "rowgroup.h"
|
|
|
|
namespace funcexp
|
|
{
|
|
execplan::CalpontSystemCatalog::ColType Func_json_quote::operationType(
|
|
FunctionParm& fp, execplan::CalpontSystemCatalog::ColType& /*resultType*/)
|
|
{
|
|
return fp[0]->data()->resultType();
|
|
}
|
|
|
|
std::string Func_json_quote::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull,
|
|
execplan::CalpontSystemCatalog::ColType& /*type*/)
|
|
{
|
|
const auto js = fp[0]->data()->getStrVal(row, isNull);
|
|
if (isNull || !isCharType(fp[0]->data()->resultType().colDataType))
|
|
{
|
|
isNull = true;
|
|
return "";
|
|
}
|
|
|
|
// Use Glaze to emit a JSON-escaped, quoted string
|
|
const std::string_view sv = js.unsafeStringRef();
|
|
std::string out;
|
|
if (auto err = writeJson(sv, out))
|
|
{
|
|
isNull = true;
|
|
return "";
|
|
}
|
|
return out;
|
|
}
|
|
} // namespace funcexp
|