diff --git a/velox/functions/sparksql/specialforms/FromJson.cpp b/velox/functions/sparksql/specialforms/FromJson.cpp index 0edc8f1e4b4b..c955b3617c71 100644 --- a/velox/functions/sparksql/specialforms/FromJson.cpp +++ b/velox/functions/sparksql/specialforms/FromJson.cpp @@ -232,7 +232,7 @@ struct ExtractJsonTypeImpl { boost::algorithm::to_lower(key); } auto it = fieldIndices.find(key); - if (it != fieldIndices.end()) { + if (it != fieldIndices.end() && it->second >= 0) { const auto index = it->second; it->second = -1;