Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/src/olap/rowset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ add_library(Rowset STATIC
beta_rowset_reader.cpp
beta_rowset_writer.cpp)

target_compile_options(Rowset PUBLIC "-Wno-error=maybe-uninitialized")
target_compile_options(Rowset PUBLIC)
4 changes: 2 additions & 2 deletions be/src/olap/rowset/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Status StringColumnDirectReader::next_vector(ColumnVector* column_vector, uint32
string_buffer_size += length;
}

uint8_t* allocated_mem;
uint8_t* allocated_mem = nullptr;
res = mem_pool->allocate_safely(string_buffer_size, allocated_mem);
if (!res.ok()) {
return res;
Expand Down Expand Up @@ -229,7 +229,7 @@ Status StringColumnDirectReader::next_vector(ColumnVector* column_vector, uint32
}
}

uint8_t* allocated_mem;
uint8_t* allocated_mem = nullptr;
res = mem_pool->allocate_safely(string_buffer_size, allocated_mem);
if (!res.ok()) {
return res;
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/rowset/run_length_integer_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Status RunLengthIntegerReader::_read_values() {
Status res = Status::OK();

// read the first 2 bits and determine the encoding type
uint8_t first_byte;
uint8_t first_byte = 0;

res = _input->read((char*)&first_byte);
if (!res.ok()) {
Expand Down Expand Up @@ -311,7 +311,7 @@ Status RunLengthIntegerReader::_read_direct_values(uint8_t first_byte) {

// extract the run length
int32_t len = (first_byte & 0x01) << 8;
uint8_t byte;
uint8_t byte = 0;

res = _input->read((char*)&byte);
if (!res.ok()) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/tools/meta_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void get_meta(DataDir* data_dir) {
std::string value;
Status s =
TabletMetaManager::get_json_meta(data_dir, FLAGS_tablet_id, FLAGS_schema_hash, &value);
if (s == doris::Status::OLAPInternalError(OLAP_ERR_META_KEY_NOT_FOUND)) {
if (s == doris::Status::OLAPInternalError(doris::OLAP_ERR_META_KEY_NOT_FOUND)) {
std::cout << "no tablet meta for tablet_id:" << FLAGS_tablet_id
<< ", schema_hash:" << FLAGS_schema_hash << std::endl;
return;
Expand Down
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/org/apache/doris/PaloFe.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static void start(String dorisHomeDir, String pidDir, String[] args) {
httpServer.setWorkers(Config.jetty_server_workers);
httpServer.setMaxThreads(Config.jetty_threadPool_maxThreads);
httpServer.setMaxThreads(Config.jetty_threadPool_minThreads);
httpServer.start(dorisHomeDir);
httpServer.start();

qeService.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import org.apache.doris.httpv2.config.SpringLog4j2Config;

import com.google.common.collect.Maps;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
import org.apache.logging.log4j.core.lookup.Interpolator;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;

import com.google.common.collect.Maps;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Map;
Expand Down
10 changes: 8 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/httpv2/HttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.doris.PaloFe;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.httpv2.config.SpringLog4j2Config;

import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down Expand Up @@ -77,7 +78,7 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder applicatio
return application.sources(HttpServer.class);
}

public void start(String dorisHome) {
public void start() {
Map<String, Object> properties = new HashMap<>();
properties.put("server.port", port);
properties.put("server.servlet.context-path", "/");
Expand All @@ -101,7 +102,12 @@ public void start(String dorisHome) {
System.setProperty("spring.http.multipart.location", PaloFe.DORIS_HOME_DIR);
}
System.setProperty("spring.banner.image.location", "doris-logo.png");
properties.put("logging.config", Config.custom_config_dir + "/" + SpringLog4j2Config.SPRING_LOG_XML_FILE);
if (FeConstants.runningUnitTest) {
// this is currently only used for unit test
properties.put("logging.config", getClass().getClassLoader().getResource("log4j2.xml").getPath());
} else {
properties.put("logging.config", Config.custom_config_dir + "/" + SpringLog4j2Config.SPRING_LOG_XML_FILE);
}
new SpringApplicationBuilder()
.sources(HttpServer.class)
.properties(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void startService(String dorisHomeDir) throws IllegalArgException, IOExc

HttpServer httpServer = new HttpServer();
httpServer.setPort(Config.http_port);
httpServer.start(dorisHomeDir);
httpServer.start();

// MySQl server
QeService qeService = new QeService(Config.query_port, Config.mysql_service_nio_enabled, ExecuteEnv.getInstance().getScheduler());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
import org.apache.doris.catalog.TabletInvertedIndex;
import org.apache.doris.catalog.TabletMeta;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.ExceptionChecker.ThrowingRunnable;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.jmockit.Deencapsulation;
import org.apache.doris.httpv2.HttpServer;
import org.apache.doris.httpv2.IllegalArgException;
Expand All @@ -53,14 +53,18 @@
import org.apache.doris.thrift.TStorageMedium;
import org.apache.doris.thrift.TStorageType;

import com.google.common.base.Strings;
import com.google.common.collect.Lists;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

import java.io.File;
import java.io.IOException;
import java.net.ServerSocket;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -113,7 +117,19 @@ abstract public class DorisHttpTestCase {

protected String rootAuth = Credentials.basic("root", "");

public static final String DORIS_HOME_DIR = System.getenv("DORIS_HOME");
private static final String DORIS_HOME;

static {
String dorisHome = System.getenv("DORIS_HOME");
if (Strings.isNullOrEmpty(dorisHome)) {
try {
dorisHome = Files.createTempDirectory("DORIS_HOME").toAbsolutePath().toString();
} catch (IOException e) {
e.printStackTrace();
}
}
DORIS_HOME = dorisHome;
}

@Mocked
private static EditLog editLog;
Expand Down Expand Up @@ -296,15 +312,21 @@ public static void initHttpServer() throws IllegalArgException, InterruptedExcep
}
}

FeConstants.runningUnitTest = true;
httpServer = new HttpServer();
httpServer.setPort(Config.http_port);
httpServer.setMaxHttpPostSize(Config.jetty_server_max_http_post_size);
httpServer.setAcceptors(Config.jetty_server_acceptors);
httpServer.setSelectors(Config.jetty_server_selectors);
httpServer.setWorkers(Config.jetty_server_workers);
httpServer.start(DORIS_HOME_DIR);
httpServer.setPort(HTTP_PORT);
httpServer.setMaxHttpPostSize(100 * 1024 * 1024);
httpServer.setAcceptors(2);
httpServer.setSelectors(4);
httpServer.setWorkers(0);
httpServer.start();
}

@AfterClass
public static void afterClass() {
File file = new File(DORIS_HOME);
file.delete();
}


@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void testQueryPlanAction() throws IOException, TException {
String respStr = response.body().string();
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
System.out.println(respStr);
Assert.assertEquals(200, (long) jsonObject.get("status"));
Assert.assertEquals(200, (long) ((JSONObject) jsonObject.get("data")).get("status"));

JSONObject partitionsObject = (JSONObject) jsonObject.get("partitions");
JSONObject partitionsObject = (JSONObject) ((JSONObject) jsonObject.get("data")).get("partitions");
Assert.assertNotNull(partitionsObject);
for (Object tabletKey : partitionsObject.keySet()) {
JSONObject tabletObject = (JSONObject) partitionsObject.get(tabletKey);
Expand All @@ -70,7 +70,7 @@ public void testQueryPlanAction() throws IOException, TException {
Assert.assertEquals(testSchemaHash, (long) tabletObject.get("schemaHash"));

}
String queryPlan = (String) jsonObject.get("opaqued_query_plan");
String queryPlan = (String) ((JSONObject) jsonObject.get("data")).get("opaqued_query_plan");
Assert.assertNotNull(queryPlan);
byte[] binaryPlanInfo = Base64.getDecoder().decode(queryPlan);
TDeserializer deserializer = new TDeserializer();
Expand All @@ -93,8 +93,8 @@ public void testNoSqlFailure() throws IOException {
System.out.println(respStr);
Assert.assertNotNull(respStr);
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(400, (long) jsonObject.get("status"));
String exception = (String) jsonObject.get("exception");
Assert.assertEquals(403, (long) jsonObject.get("code"));
String exception = (String) jsonObject.get("data");
Assert.assertNotNull(exception);
Assert.assertEquals("POST body must contains [sql] root object", exception);
}
Expand All @@ -112,8 +112,8 @@ public void testEmptySqlFailure() throws IOException {
System.out.println(respStr);
Assert.assertNotNull(respStr);
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(400, (long) jsonObject.get("status"));
String exception = (String) jsonObject.get("exception");
Assert.assertEquals(403, (long) jsonObject.get("code"));
String exception = (String) jsonObject.get("data");
Assert.assertNotNull(exception);
Assert.assertEquals("POST body must contains [sql] root object", exception);
}
Expand All @@ -131,8 +131,8 @@ public void testInconsistentResource() throws IOException {
System.out.println(respStr);
Assert.assertNotNull(respStr);
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(400, (long) jsonObject.get("status"));
String exception = (String) jsonObject.get("exception");
Assert.assertEquals(400, (long) ((JSONObject) jsonObject.get("data")).get("status"));
String exception = (String) ((JSONObject) jsonObject.get("data")).get("exception");
Assert.assertNotNull(exception);
Assert.assertTrue(exception.startsWith("requested database and table must consistent with sql"));
}
Expand All @@ -149,15 +149,15 @@ public void testMalformedJson() throws IOException {
String respStr = response.body().string();
Assert.assertNotNull(respStr);
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(400, (long) jsonObject.get("status"));
String exception = (String) jsonObject.get("exception");
Assert.assertEquals(403, (long) jsonObject.get("code"));
String exception = (String) jsonObject.get("data");
Assert.assertNotNull(exception);
Assert.assertTrue(exception.startsWith("malformed json"));
}

@Test
public void testNotOlapTableFailure() throws IOException {
RequestBody body = RequestBody.create(JSON, "{ \"sql\" : \" select k1,k2 from " + DB_NAME + ".es_table" + " \" }");
RequestBody body = RequestBody.create("{ \"sql\" : \" select k1,k2 from " + DB_NAME + ".es_table" + " \" }", JSON);
Request request = new Request.Builder()
.post(body)
.addHeader("Authorization", rootAuth)
Expand All @@ -167,8 +167,9 @@ public void testNotOlapTableFailure() throws IOException {
String respStr = response.body().string();
Assert.assertNotNull(respStr);
JSONObject jsonObject = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(403, (long) jsonObject.get("status"));
String exception = (String) jsonObject.get("exception");
System.out.println(respStr);
Assert.assertEquals(1, (long) jsonObject.get("code"));
String exception = (String) jsonObject.get("data");
Assert.assertTrue(exception.contains("table type is not OLAP"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public void testTableCount() throws IOException {
.build();

Response response = networkClient.newCall(request).execute();
JSONObject jsonObject = (JSONObject) JSONValue.parse(response.body().string());
Assert.assertEquals(200, (long) jsonObject.get("status"));
Assert.assertEquals(2000, (long) jsonObject.get("size"));
String res = response.body().string();
System.out.println(res);
JSONObject jsonObject = (JSONObject) JSONValue.parse(res);
Assert.assertEquals(200, (long) ((JSONObject) jsonObject.get("data")).get("status"));
Assert.assertEquals(2000, (long) ((JSONObject) jsonObject.get("data")).get("size"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void testGetTableSchema() throws IOException {
String respStr = response.body().string();
Assert.assertNotNull(respStr);
JSONObject object = (JSONObject) JSONValue.parse(respStr);
Assert.assertEquals(200, (long) object.get("status"));
JSONArray propArray = (JSONArray) object.get("properties");
Assert.assertEquals(200, (long) ((JSONObject) object.get("data")).get("status"));
JSONArray propArray = (JSONArray) ((JSONObject) object.get("data")).get("properties");
// k1, k2
Assert.assertEquals(2, propArray.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package org.apache.doris.rewrite;

import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.FeConstants;
import org.apache.doris.utframe.DorisAssert;
import org.apache.doris.utframe.UtFrameUtils;
Expand Down Expand Up @@ -256,62 +255,55 @@ public void testRewriteLikePredicate() throws Exception {
// tinyint
String sql = "select * from tb3 where k1 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainContains("CAST(`k1` AS CHARACTER) LIKE '%4%'");
dorisAssert.query(sql).explainContains("`k1` LIKE '%4%'");

// smallint
sql = "select * from tb3 where k2 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainContains("CAST(`k2` AS CHARACTER) LIKE '%4%'");
dorisAssert.query(sql).explainContains("`k2` LIKE '%4%'");

// int
sql = "select * from tb3 where k3 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainContains("CAST(`k3` AS CHARACTER) LIKE '%4%'");
dorisAssert.query(sql).explainContains("`k3` LIKE '%4%'");

// bigint
sql = "select * from tb3 where k4 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainContains("CAST(`k4` AS CHARACTER) LIKE '%4%'");
dorisAssert.query(sql).explainContains("`k4` LIKE '%4%'");

// largeint
sql = "select * from tb3 where k5 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainContains("CAST(`k5` AS CHARACTER) LIKE '%4%'");
dorisAssert.query(sql).explainContains("`k5` LIKE '%4%'");
}

@Test(expected = AnalysisException.class)
@Test
public void testRewriteLikePredicateDate() throws Exception {
// date
String sql = "select * from tb3 where k6 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainQuery();
Assert.fail("No exception throws.");
}

@Test(expected = AnalysisException.class)
@Test
public void testRewriteLikePredicateDateTime() throws Exception {
// datetime
String sql = "select * from tb3 where k7 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainQuery();
Assert.fail("No exception throws.");
}

@Test(expected = AnalysisException.class)
@Test
public void testRewriteLikePredicateFloat() throws Exception {
// date
String sql = "select * from tb3 where k8 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainQuery();
Assert.fail("No exception throws.");
}

@Test(expected = AnalysisException.class)
@Test
public void testRewriteLikePredicateDouble() throws Exception {
// date
String sql = "select * from tb3 where k9 like '%4%';";
LOG.info("EXPLAIN:{}", dorisAssert.query(sql).explainQuery());
dorisAssert.query(sql).explainQuery();
Assert.fail("No exception throws.");
}
}