@@ -724,6 +724,48 @@ Status StreamLoadAction::_process_put(HttpRequest* http_req,
724724 request.__set_cloud_cluster (http_req->header (HTTP_CLOUD_CLUSTER));
725725 }
726726
727+ if (config::enable_http_stream_load) {
728+ std::string table_name = ctx->table ;
729+ std::string database_name = request.db ;
730+
731+ std::string columns = http_req->header (HTTP_COLUMNS);
732+ if (columns.empty ()) {
733+ return Status::InvalidArgument (" Missing required HTTP header: columns" );
734+ }
735+
736+ std::string column_separator = http_req->header (HTTP_COLUMN_SEPARATOR).empty ()
737+ ? " ,"
738+ : http_req->header (HTTP_COLUMN_SEPARATOR);
739+
740+ std::string format =
741+ http_req->header (" format" ).empty () ? " csv" : http_req->header (" format" );
742+
743+ std::vector<std::string> column_vector = split (columns, std::string (" ," ));
744+ std::string column_list = " (" + join (column_vector, " , " ) + " )" ;
745+
746+ std::vector<std::string> sql_parts;
747+ sql_parts.emplace_back (" SELECT " + join (column_vector, " , " ));
748+
749+ std::string http_stream_params = " http_stream('format' = '" + format +
750+ " ', 'column_separator' = '" + column_separator + " ')" ;
751+
752+ sql_parts.emplace_back (" FROM " + http_stream_params);
753+
754+ if (!http_req->header (HTTP_WHERE).empty ()) {
755+ sql_parts.emplace_back (" WHERE " + http_req->header (HTTP_WHERE));
756+ }
757+
758+ std::string full_sql =
759+ " INSERT INTO " + database_name + " ." + table_name + " " + column_list + " " ;
760+ for (size_t i = 0 ; i < sql_parts.size (); i++) {
761+ full_sql += sql_parts[i];
762+ if (i != sql_parts.size () - 1 ) full_sql += " " ;
763+ }
764+
765+ ctx->sql_str = full_sql;
766+ LOG (INFO) << " Generated SQL: " << full_sql << ctx->to_json ();
767+ }
768+
727769#ifndef BE_TEST
728770 // plan this load
729771 TNetworkAddress master_addr = _exec_env->cluster_info ()->master_fe_addr ;
0 commit comments