You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/02/05 04:11:42 UTC
[doris] branch branch-1.2-lts updated (fb5420c262 -> acb7b675b4)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a change to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
from fb5420c262 [improvement](multi-catalog) increase default batch_size to 4064 (#16326)
new 085fe7e4a9 [fix](scan) coredump caused by null of _scanner_ctx (#16361)
new dc665d2d35 [bug](jdbc) fix jdbc insert decimalv3 be core dump (#16353)
new e6fedf3cae [fix](auth)fix external catalog cannot use db (#16269)
new 6746b360a2 [bug](function) fix mask_first_n function can't handle const value (#16308)
new 9e8b52f49e [fix](broker) Fix bug that heavy broker load may failed due to BrokerException which indicate the fd is not owned by client (#16350)
new 5a680655d2 [Bug](CURRENT_TIMESTAMP) Fix wrong default value after schema change (#16364)
new d12a370447 [Bug](datev2) Fix bug when cast datev2 to date (#16394)
new 168cacc106 [fix](planner) Doris returns empty sets when select from a inline view (#16370)
new 69e99daf30 [bugfix](disk balance) fix new rowset time check when add tablet (#16261)
new bf58cc6fe1 [Bug](date) Fix BE crash caused by function `datediff` (#16397)
new 711ccf5967 [fix](memory) Fix request jemallloc metrics wait lock je_malloc_mutex_lock_slow #16381
new 0c6fd47c92 [Enhancement](Stmt)ShowPartitionsStmt support forward to master #16359
new deb35dbb32 [Enhancement](profile) lazy load profileContent string (#16354)
new 62ed78d339 [enhancement](profile) add the profile counter RawRowsRead to record the rows read from the parquet file (#16328)
new acb7b675b4 [fix](vertical compaction) fix uint32_t init value (#16377)
The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
be/src/common/daemon.cpp | 1 +
be/src/exec/table_connector.cpp | 3 +-
be/src/olap/tablet_manager.cpp | 2 +-
be/src/runtime/memory/jemalloc_hook.cpp | 3 ++
be/src/util/system_metrics.cpp | 3 ++
be/src/util/system_metrics.h | 1 +
be/src/vec/exec/format/parquet/vparquet_reader.cpp | 3 ++
be/src/vec/exec/format/parquet/vparquet_reader.h | 1 +
be/src/vec/exec/scan/vscan_node.cpp | 10 +++-
be/src/vec/functions/function_cast.h | 9 ++--
.../function_date_or_datetime_computation.h | 4 +-
be/src/vec/functions/function_string.h | 6 +--
be/src/vec/olap/vertical_merge_iterator.h | 8 ++--
.../java/org/apache/doris/analysis/ColumnDef.java | 20 ++++++--
.../java/org/apache/doris/analysis/SelectStmt.java | 8 +++-
.../apache/doris/analysis/ShowPartitionsStmt.java | 9 ++++
.../java/org/apache/doris/analysis/SlotRef.java | 5 ++
.../java/org/apache/doris/analysis/UseStmt.java | 4 +-
.../main/java/org/apache/doris/catalog/Column.java | 32 +++++++++++--
.../main/java/org/apache/doris/catalog/Env.java | 2 +-
.../apache/doris/common/util/ProfileManager.java | 23 +++++++--
.../doris/datasource/HMSExternalCatalog.java | 4 +-
.../org/apache/doris/external/jdbc/JdbcClient.java | 4 +-
.../org/apache/doris/analysis/QueryStmtTest.java | 2 +-
.../apache/doris/mysql/privilege/MockedAuth.java | 4 ++
.../org/apache/doris/planner/QueryPlanTest.java | 13 ------
.../apache/doris/broker/hdfs/BrokerFileSystem.java | 2 +-
.../doris/broker/hdfs/ClientContextManager.java | 23 ++++++---
.../{test_invalid_date.out => test_date_exprs.out} | 4 +-
.../date/test_default_current_timestamp.out} | 1 +
.../datetime_functions/test_date_function.out | 3 ++
.../subquery/test_subquery2.out} | 7 ++-
..._invalid_date.groovy => test_date_exprs.groovy} | 29 ++++++------
.../date/test_default_current_timestamp.groovy | 54 ++++++++++++++++++++++
.../datetime_functions/test_date_function.groovy | 1 +
.../subquery/test_subquery2.groovy} | 24 ++++++----
36 files changed, 247 insertions(+), 85 deletions(-)
copy regression-test/data/datatype_p0/date/{test_invalid_date.out => test_date_exprs.out} (84%)
copy regression-test/data/{query_p0/literal_view/lietral_test.out => datatype_p0/date/test_default_current_timestamp.out} (98%)
copy regression-test/data/{datev2/ssb_sf1_p1/sql/flat_q1.1.out => query_p0/subquery/test_subquery2.out} (76%)
copy regression-test/suites/datatype_p0/date/{test_invalid_date.groovy => test_date_exprs.groovy} (61%)
create mode 100644 regression-test/suites/datatype_p0/date/test_default_current_timestamp.groovy
copy regression-test/suites/{nereids_syntax_p0/group_by_constant.groovy => query_p0/subquery/test_subquery2.groovy} (59%)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 08/15: [fix](planner) Doris returns empty sets when select from a inline view (#16370)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 168cacc106c939eca12c6e8f83af49ded4d647ad
Author: AKIRA <33...@users.noreply.github.com>
AuthorDate: Fri Feb 3 21:23:52 2023 +0800
[fix](planner) Doris returns empty sets when select from a inline view (#16370)
Doris always delays the execution of expressions as possible as it can, so as the expansion of constant expression. Given below SQL:
```sql
select i from (select 'abc' as i, sum(birth) as j from subquerytest2) as tmp
```
The aggregation would be eliminated, since its output is not required by the outer block, but the expasion for constant expression would be done in the final result expr, and since aggreagete output has been eliminate, the expasion would actually do nothing, and finally cause a empty results.
To fix this, we materialize the results expr in the inner block for such SQL, it may affect performance, but better than let system produce a mistaken result.
---
.../java/org/apache/doris/analysis/SelectStmt.java | 8 ++++-
.../java/org/apache/doris/analysis/SlotRef.java | 5 +++
.../org/apache/doris/analysis/QueryStmtTest.java | 2 +-
.../org/apache/doris/planner/QueryPlanTest.java | 13 --------
.../data/query_p0/subquery/test_subquery2.out | 7 +++++
.../suites/query_p0/subquery/test_subquery2.groovy | 36 ++++++++++++++++++++++
6 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 8f47a9ed04..921af16eec 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -407,7 +407,6 @@ public class SelectStmt extends QueryStmt {
super.analyze(analyzer);
fromClause.setNeedToSql(needToSql);
fromClause.analyze(analyzer);
-
// Generate !empty() predicates to filter out empty collections.
// Skip this step when analyzing a WITH-clause because CollectionTableRefs
// do not register collection slots in their parent in that context
@@ -757,6 +756,13 @@ public class SelectStmt extends QueryStmt {
lateralViewRef.materializeRequiredSlots(baseTblSmap, analyzer);
}
}
+ boolean hasConstant = resultExprs.stream().anyMatch(Expr::isConstant);
+ // In such case, agg output must be materialized whether outer query block required or not.
+ if (tableRef instanceof InlineViewRef && hasConstant) {
+ InlineViewRef inlineViewRef = (InlineViewRef) tableRef;
+ QueryStmt queryStmt = inlineViewRef.getQueryStmt();
+ queryStmt.resultExprs.forEach(Expr::materializeSrcExpr);
+ }
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
index 0650acfb28..bfd9ab9ccb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java
@@ -34,6 +34,7 @@ import org.apache.doris.thrift.TSlotRef;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -339,6 +340,10 @@ public class SlotRef extends Expr {
@Override
protected boolean isConstantImpl() {
+ if (desc != null) {
+ List<Expr> exprs = desc.getSourceExprs();
+ return CollectionUtils.isNotEmpty(exprs) && exprs.stream().allMatch(Expr::isConstant);
+ }
return false;
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
index 130c23d427..03acde255d 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/QueryStmtTest.java
@@ -210,7 +210,7 @@ public class QueryStmtTest {
Assert.assertEquals(5, exprsMap.size());
constMap.clear();
constMap = getConstantExprMap(exprsMap, analyzer);
- Assert.assertEquals(1, constMap.size());
+ Assert.assertEquals(2, constMap.size());
// expr in subquery associate with column in grandparent level
sql = "WITH aa AS\n"
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index 115cdfcc9a..f2085315ef 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -1798,19 +1798,6 @@ public class QueryPlanTest extends TestWithFeService {
Assert.assertTrue(explainString.contains("PREDICATES: `k11` > '2021-06-01 00:00:00'"));
}
- @Test
- public void testNullColumnViewOrderBy() throws Exception {
- FeConstants.runningUnitTest = true;
- connectContext.setDatabase("default_cluster:test");
- String sql = "select * from tbl_null_column_view where add_column is not null;";
- String explainString1 = getSQLPlanOrErrorMsg("EXPLAIN " + sql);
- Assert.assertTrue(explainString1.contains("EMPTYSET"));
-
- String sql2 = "select * from tbl_null_column_view where add_column is not null order by query_id;";
- String explainString2 = getSQLPlanOrErrorMsg("EXPLAIN " + sql2);
- Assert.assertTrue(explainString2.contains("EMPTYSET"));
- }
-
@Test
public void testCompoundPredicateWriteRule() throws Exception {
connectContext.setDatabase("default_cluster:test");
diff --git a/regression-test/data/query_p0/subquery/test_subquery2.out b/regression-test/data/query_p0/subquery/test_subquery2.out
new file mode 100644
index 0000000000..1061df5495
--- /dev/null
+++ b/regression-test/data/query_p0/subquery/test_subquery2.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql_1 --
+abc
+
+-- !sql_2 --
+bc
+
diff --git a/regression-test/suites/query_p0/subquery/test_subquery2.groovy b/regression-test/suites/query_p0/subquery/test_subquery2.groovy
new file mode 100644
index 0000000000..d8476ebbdc
--- /dev/null
+++ b/regression-test/suites/query_p0/subquery/test_subquery2.groovy
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_subquery2") {
+
+ sql """DROP TABLE IF EXISTS subquerytest2"""
+
+ sql """
+ CREATE TABLE subquerytest2 (birth int)UNIQUE KEY(birth)DISTRIBUTED BY HASH (birth)
+ BUCKETS 1 PROPERTIES("replication_allocation" = "tag.location.default: 1");
+ """
+
+ sql """insert into subquerytest2 values (2)"""
+
+
+ qt_sql_1 """select i from (select 'abc' as i, sum(birth) as j from subquerytest2) as tmp"""
+
+ qt_sql_2 """select substring(i, 2) from (select 'abc' as i, sum(birth) as j from subquerytest2) as tmp"""
+
+ sql """DROP TABLE subquerytest2"""
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 12/15: [Enhancement](Stmt)ShowPartitionsStmt support forward to master #16359
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 0c6fd47c9231e6db8ac17ac668e37d0cbc6b9270
Author: Xujian Duan <50...@users.noreply.github.com>
AuthorDate: Sat Feb 4 22:51:19 2023 +0800
[Enhancement](Stmt)ShowPartitionsStmt support forward to master #16359
Co-authored-by: duanxujian <du...@jd.com>
---
.../main/java/org/apache/doris/analysis/ShowPartitionsStmt.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
index 1e79ef8f54..6114bc83a0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
@@ -271,4 +271,13 @@ public class ShowPartitionsStmt extends ShowStmt {
return toSql();
}
+ @Override
+ public RedirectStatus getRedirectStatus() {
+ if (ConnectContext.get().getSessionVariable().getForwardToMaster()) {
+ return RedirectStatus.FORWARD_NO_SYNC;
+ } else {
+ return RedirectStatus.NO_FORWARD;
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 05/15: [fix](broker) Fix bug that heavy broker load may failed due to BrokerException which indicate the fd is not owned by client (#16350)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 9e8b52f49e49ea4618167d6954db1b61eed3b1af
Author: caiconghui <55...@users.noreply.github.com>
AuthorDate: Fri Feb 3 15:06:45 2023 +0800
[fix](broker) Fix bug that heavy broker load may failed due to BrokerException which indicate the fd is not owned by client (#16350)
Co-authored-by: caiconghui1 <ca...@jd.com>
---
.../apache/doris/broker/hdfs/BrokerFileSystem.java | 2 +-
.../doris/broker/hdfs/ClientContextManager.java | 23 +++++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/BrokerFileSystem.java b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/BrokerFileSystem.java
index c8a217d205..22f6925d31 100644
--- a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/BrokerFileSystem.java
+++ b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/BrokerFileSystem.java
@@ -31,7 +31,7 @@ public class BrokerFileSystem {
private ReentrantLock lock;
private FileSystemIdentity identity;
private FileSystem dfsFileSystem;
- private long lastAccessTimestamp;
+ private volatile long lastAccessTimestamp;
private long createTimestamp;
private UUID fileSystemId;
diff --git a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/ClientContextManager.java b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/ClientContextManager.java
index e52f248e11..736f9ae448 100644
--- a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/ClientContextManager.java
+++ b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/ClientContextManager.java
@@ -131,7 +131,7 @@ public class ClientContextManager {
public void run() {
try {
for (ClientResourceContext clientContext : clientContexts.values()) {
- if (System.currentTimeMillis() - clientContext.lastPingTimestamp > clientExpirationSeconds * 1000) {
+ if (System.currentTimeMillis() - clientContext.lastAccessTimestamp > clientExpirationSeconds * 1000) {
for (TBrokerFD fd : clientContext.inputStreams.keySet()) {
ClientContextManager.this.removeInputStream(fd);
}
@@ -139,9 +139,9 @@ public class ClientContextManager {
ClientContextManager.this.removeOutputStream(fd);
}
clientContexts.remove(clientContext.clientId);
- logger.info("client [" + clientContext.clientId
- + "] is expired, remove it from contexts. last ping time is "
- + clientContext.lastPingTimestamp);
+ logger.info("client [" + clientContext.clientId
+ + "] is expired, remove it from contexts. last access time is "
+ + clientContext.lastAccessTimestamp);
}
}
} finally {
@@ -197,24 +197,28 @@ public class ClientContextManager {
private String clientId;
private ConcurrentHashMap<TBrokerFD, BrokerInputStream> inputStreams;
private ConcurrentHashMap<TBrokerFD, BrokerOutputStream> outputStreams;
- private long lastPingTimestamp;
+
+ private volatile long lastAccessTimestamp;
public ClientResourceContext(String clientId) {
this.clientId = clientId;
this.inputStreams = new ConcurrentHashMap<>();
this.outputStreams = new ConcurrentHashMap<>();
- this.lastPingTimestamp = System.currentTimeMillis();
+ this.lastAccessTimestamp = System.currentTimeMillis();
}
public void putInputStream(TBrokerFD fd, FSDataInputStream inputStream, BrokerFileSystem fileSystem) {
+ updateLastAccessTime();
inputStreams.putIfAbsent(fd, new BrokerInputStream(inputStream, fileSystem));
}
public void putOutputStream(TBrokerFD fd, FSDataOutputStream outputStream, BrokerFileSystem fileSystem) {
+ updateLastAccessTime();
outputStreams.putIfAbsent(fd, new BrokerOutputStream(outputStream, fileSystem));
}
public FSDataInputStream getInputStream(TBrokerFD fd) {
+ updateLastAccessTime();
BrokerInputStream brokerInputStream = inputStreams.get(fd);
if (brokerInputStream != null) {
return brokerInputStream.getInputStream();
@@ -223,6 +227,7 @@ public class ClientContextManager {
}
public FSDataOutputStream getOutputStream(TBrokerFD fd) {
+ updateLastAccessTime();
BrokerOutputStream brokerOutputStream = outputStreams.get(fd);
if (brokerOutputStream != null) {
return brokerOutputStream.getOutputStream();
@@ -230,8 +235,12 @@ public class ClientContextManager {
return null;
}
+ public void updateLastAccessTime() {
+ this.lastAccessTimestamp = System.currentTimeMillis();
+ }
+
public void updateLastPingTime() {
- this.lastPingTimestamp = System.currentTimeMillis();
+ this.lastAccessTimestamp = System.currentTimeMillis();
// Should we also update the underline filesystem? maybe it is time cost
for (BrokerInputStream brokerInputStream : inputStreams.values()) {
brokerInputStream.updateLastUpdateAccessTime();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 11/15: [fix](memory) Fix request jemallloc metrics wait lock je_malloc_mutex_lock_slow #16381
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 711ccf596775303f94f040df90e2e468376fa8f8
Author: Xinyi Zou <zo...@gmail.com>
AuthorDate: Sat Feb 4 22:49:22 2023 +0800
[fix](memory) Fix request jemallloc metrics wait lock je_malloc_mutex_lock_slow #16381
MetricRegistry::trigger_all_hooks holds the metrics lock and is stuck in get_je_metrics, to_prometheus is waiting for MetricRegistry::trigger_all_hooks to release the lock, so get_je_metrics is no longer called in MetricRegistry::trigger_all_hooks.
---
be/src/common/daemon.cpp | 1 +
be/src/runtime/memory/jemalloc_hook.cpp | 3 +++
be/src/util/system_metrics.cpp | 3 +++
be/src/util/system_metrics.h | 1 +
4 files changed, 8 insertions(+)
diff --git a/be/src/common/daemon.cpp b/be/src/common/daemon.cpp
index 2f6afb99b7..b80787cb4e 100644
--- a/be/src/common/daemon.cpp
+++ b/be/src/common/daemon.cpp
@@ -218,6 +218,7 @@ void Daemon::memory_maintenance_thread() {
// Refresh allocator memory metrics.
#if !defined(ADDRESS_SANITIZER) && !defined(LEAK_SANITIZER) && !defined(THREAD_SANITIZER)
doris::MemInfo::refresh_allocator_mem();
+ DorisMetrics::instance()->system_metrics()->update_allocator_metrics();
#endif
doris::MemInfo::refresh_proc_mem_no_allocator_cache();
diff --git a/be/src/runtime/memory/jemalloc_hook.cpp b/be/src/runtime/memory/jemalloc_hook.cpp
index bf0c3e20bc..1558776331 100644
--- a/be/src/runtime/memory/jemalloc_hook.cpp
+++ b/be/src/runtime/memory/jemalloc_hook.cpp
@@ -28,6 +28,9 @@
extern "C" {
void* doris_malloc(size_t size) __THROW {
+ // Both je_nallocx and je_malloc will use the lock je_malloc_mutex_lock_slow,
+ // so enabling the jemalloc hook will double the lock usage.
+ // In extreme cases this will affect performance, consider turning off mem hook
TRY_CONSUME_MEM_TRACKER(je_nallocx(size, 0), nullptr);
void* ptr = je_malloc(size);
if (UNLIKELY(ptr == nullptr)) {
diff --git a/be/src/util/system_metrics.cpp b/be/src/util/system_metrics.cpp
index 11703f2187..5e94b7ce79 100644
--- a/be/src/util/system_metrics.cpp
+++ b/be/src/util/system_metrics.cpp
@@ -430,6 +430,9 @@ void SystemMetrics::_install_memory_metrics(MetricEntity* entity) {
void SystemMetrics::_update_memory_metrics() {
_memory_metrics->memory_allocated_bytes->set_value(PerfCounters::get_vm_rss());
get_metrics_from_proc_vmstat();
+}
+
+void SystemMetrics::update_allocator_metrics() {
#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || defined(THREAD_SANITIZER)
LOG(INFO) << "Memory tracking is not available with address sanitizer builds.";
#elif defined(USE_JEMALLOC)
diff --git a/be/src/util/system_metrics.h b/be/src/util/system_metrics.h
index 5354f494de..8f54aa9440 100644
--- a/be/src/util/system_metrics.h
+++ b/be/src/util/system_metrics.h
@@ -55,6 +55,7 @@ public:
int64_t interval_sec);
void update_max_network_send_bytes_rate(int64_t max_send_bytes_rate);
void update_max_network_receive_bytes_rate(int64_t max_receive_bytes_rate);
+ void update_allocator_metrics();
private:
void _install_cpu_metrics();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 04/15: [bug](function) fix mask_first_n function can't handle const value (#16308)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 6746b360a247b7d5165c4c6592dd20a5ea592325
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Fri Feb 3 10:32:42 2023 +0800
[bug](function) fix mask_first_n function can't handle const value (#16308)
---
be/src/vec/functions/function_string.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function_string.h b/be/src/vec/functions/function_string.h
index b37670808e..eae5da53b3 100644
--- a/be/src/vec/functions/function_string.h
+++ b/be/src/vec/functions/function_string.h
@@ -419,8 +419,8 @@ public:
int n = -1;
auto res = ColumnString::create();
- const ColumnString& source_column =
- assert_cast<const ColumnString&>(*block.get_by_position(arguments[0]).column);
+ auto col = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
+ const ColumnString& source_column = assert_cast<const ColumnString&>(*col);
if (arguments.size() == 2) {
auto& col = *block.get_by_position(arguments[1]).column;
@@ -434,7 +434,7 @@ public:
FunctionMask::vector_mask(source_column, *res, FunctionMask::DEFAULT_UPPER_MASK,
FunctionMask::DEFAULT_LOWER_MASK,
FunctionMask::DEFAULT_NUMBER_MASK);
- } else if (n > 0) {
+ } else if (n >= 0) {
vector(source_column, n, *res);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 14/15: [enhancement](profile) add the profile counter RawRowsRead to record the rows read from the parquet file (#16328)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 62ed78d339918266fb678a00c8c868694183a5d0
Author: luozenglin <37...@users.noreply.github.com>
AuthorDate: Sat Feb 4 22:59:34 2023 +0800
[enhancement](profile) add the profile counter RawRowsRead to record the rows read from the parquet file (#16328)
---
be/src/vec/exec/format/parquet/vparquet_reader.cpp | 3 +++
be/src/vec/exec/format/parquet/vparquet_reader.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/be/src/vec/exec/format/parquet/vparquet_reader.cpp b/be/src/vec/exec/format/parquet/vparquet_reader.cpp
index cfc904d607..ea7446ad69 100644
--- a/be/src/vec/exec/format/parquet/vparquet_reader.cpp
+++ b/be/src/vec/exec/format/parquet/vparquet_reader.cpp
@@ -67,6 +67,8 @@ void ParquetReader::_init_profile() {
ADD_CHILD_COUNTER(_profile, "FilteredRowsByLazyRead", TUnit::UNIT, parquet_profile);
_parquet_profile.filtered_bytes =
ADD_CHILD_COUNTER(_profile, "FilteredBytes", TUnit::BYTES, parquet_profile);
+ _parquet_profile.raw_rows_read =
+ ADD_CHILD_COUNTER(_profile, "RawRowsRead", TUnit::UNIT, parquet_profile);
_parquet_profile.to_read_bytes =
ADD_CHILD_COUNTER(_profile, "ReadBytes", TUnit::BYTES, parquet_profile);
_parquet_profile.column_read_time =
@@ -108,6 +110,7 @@ void ParquetReader::close() {
COUNTER_UPDATE(_parquet_profile.lazy_read_filtered_rows,
_statistics.lazy_read_filtered_rows);
COUNTER_UPDATE(_parquet_profile.filtered_bytes, _statistics.filtered_bytes);
+ COUNTER_UPDATE(_parquet_profile.raw_rows_read, _statistics.read_rows);
COUNTER_UPDATE(_parquet_profile.to_read_bytes, _statistics.read_bytes);
COUNTER_UPDATE(_parquet_profile.column_read_time, _statistics.column_read_time);
COUNTER_UPDATE(_parquet_profile.parse_meta_time, _statistics.parse_meta_time);
diff --git a/be/src/vec/exec/format/parquet/vparquet_reader.h b/be/src/vec/exec/format/parquet/vparquet_reader.h
index f174e695e2..81c0e2b28a 100644
--- a/be/src/vec/exec/format/parquet/vparquet_reader.h
+++ b/be/src/vec/exec/format/parquet/vparquet_reader.h
@@ -111,6 +111,7 @@ private:
RuntimeProfile::Counter* filtered_page_rows;
RuntimeProfile::Counter* lazy_read_filtered_rows;
RuntimeProfile::Counter* filtered_bytes;
+ RuntimeProfile::Counter* raw_rows_read;
RuntimeProfile::Counter* to_read_bytes;
RuntimeProfile::Counter* column_read_time;
RuntimeProfile::Counter* parse_meta_time;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 03/15: [fix](auth)fix external catalog cannot use db (#16269)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit e6fedf3caec3391dd63e20d325ded8949ec73b0a
Author: zhangdong <49...@qq.com>
AuthorDate: Fri Feb 3 10:10:33 2023 +0800
[fix](auth)fix external catalog cannot use db (#16269)
---
fe/fe-core/src/main/java/org/apache/doris/analysis/UseStmt.java | 4 +++-
fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java | 2 +-
.../src/test/java/org/apache/doris/mysql/privilege/MockedAuth.java | 4 ++++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/UseStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/UseStmt.java
index be516b36f4..bb149ea15e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/UseStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/UseStmt.java
@@ -78,7 +78,9 @@ public class UseStmt extends StatementBase {
}
database = ClusterNamespace.getFullName(getClusterName(), database);
- if (!Env.getCurrentEnv().getAuth().checkDbPriv(ConnectContext.get(), database, PrivPredicate.SHOW)) {
+ if (!Env.getCurrentEnv().getAuth()
+ .checkDbPriv(ConnectContext.get(), ConnectContext.get().getDefaultCatalog(), database,
+ PrivPredicate.SHOW)) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_DBACCESS_DENIED_ERROR,
analyzer.getQualifiedUser(), database);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 42368f40da..fdb3bd738d 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -4471,7 +4471,7 @@ public class Env {
// Change current database of this session.
public void changeDb(ConnectContext ctx, String qualifiedDb) throws DdlException {
- if (!auth.checkDbPriv(ctx, qualifiedDb, PrivPredicate.SHOW)) {
+ if (!auth.checkDbPriv(ctx, ctx.getDefaultCatalog(), qualifiedDb, PrivPredicate.SHOW)) {
ErrorReport.reportDdlException(ErrorCode.ERR_DBACCESS_DENIED_ERROR, ctx.getQualifiedUser(), qualifiedDb);
}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/MockedAuth.java b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/MockedAuth.java
index 06bcd91038..a621321f63 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/MockedAuth.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/MockedAuth.java
@@ -36,6 +36,10 @@ public class MockedAuth {
minTimes = 0;
result = true;
+ auth.checkDbPriv((ConnectContext) any, anyString, anyString, (PrivPredicate) any);
+ minTimes = 0;
+ result = true;
+
auth.checkTblPriv((ConnectContext) any, anyString, anyString, (PrivPredicate) any);
minTimes = 0;
result = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 06/15: [Bug](CURRENT_TIMESTAMP) Fix wrong default value after schema change (#16364)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 5a680655d2b1c1d9ed41a50d86f0eef9741b66e3
Author: Gabriel <ga...@gmail.com>
AuthorDate: Fri Feb 3 17:06:24 2023 +0800
[Bug](CURRENT_TIMESTAMP) Fix wrong default value after schema change (#16364)
* [Bug](CURRENT_TIMESTAMP) Fix wrong default value after schema change
* update
* update
---
.../java/org/apache/doris/analysis/ColumnDef.java | 20 ++++++--
.../main/java/org/apache/doris/catalog/Column.java | 32 +++++++++++--
.../doris/datasource/HMSExternalCatalog.java | 4 +-
.../org/apache/doris/external/jdbc/JdbcClient.java | 4 +-
.../date/test_default_current_timestamp.out | 4 ++
.../date/test_default_current_timestamp.groovy | 54 ++++++++++++++++++++++
6 files changed, 106 insertions(+), 12 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index 66670db2f2..8f3097c605 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -28,11 +28,14 @@ import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeNameFormat;
+import org.apache.doris.common.util.TimeUtils;
import com.google.common.base.Preconditions;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import java.time.LocalDateTime;
+
// Column definition which is generated by SQL syntax parser
// Syntax:
// name type [key] [agg_type] [NULL | NOT NULL] [DEFAULT default_value] [comment]
@@ -95,6 +98,16 @@ public class ColumnDef {
public static DefaultValue HLL_EMPTY_DEFAULT_VALUE = new DefaultValue(true, ZERO);
// default "value", "0" means empty bitmap
public static DefaultValue BITMAP_EMPTY_DEFAULT_VALUE = new DefaultValue(true, ZERO);
+
+ public boolean isCurrentTimeStamp() {
+ return "CURRENT_TIMESTAMP".equals(value) && NOW.equals(defaultValueExprDef.getExprName());
+ }
+
+ public String getValue() {
+ return isCurrentTimeStamp()
+ ? LocalDateTime.now(TimeUtils.getTimeZone().toZoneId()).toString().replace('T', ' ')
+ : value;
+ }
}
// parameter initialized in constructor
@@ -356,12 +369,12 @@ public class ColumnDef {
break;
case DATE:
case DATEV2:
- new DateLiteral(defaultValue, ScalarType.getDefaultDateType(type));
+ new DateLiteral(defaultValue, scalarType);
break;
case DATETIME:
case DATETIMEV2:
if (defaultValueExprDef == null) {
- new DateLiteral(defaultValue, ScalarType.getDefaultDateType(type));
+ new DateLiteral(defaultValue, scalarType);
} else {
if (defaultValueExprDef.getExprName().equals(DefaultValue.NOW)) {
break;
@@ -418,7 +431,8 @@ public class ColumnDef {
public Column toColumn() {
return new Column(name, typeDef.getType(), isKey, aggregateType, isAllowNull, defaultValue.value, comment,
- visible, defaultValue.defaultValueExprDef, Column.COLUMN_UNIQUE_ID_INIT_VALUE);
+ visible, defaultValue.defaultValueExprDef, Column.COLUMN_UNIQUE_ID_INIT_VALUE,
+ defaultValue.getValue());
}
@Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
index 4416cb19ad..22ccc48bd8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
@@ -87,6 +87,16 @@ public class Column implements Writable, GsonPostProcessable {
private ColumnStats stats; // cardinality and selectivity etc.
@SerializedName(value = "children")
private List<Column> children;
+ /**
+ * This is similar as `defaultValue`. Differences are:
+ * 1. `realDefaultValue` indicates the **default underlying literal**.
+ * 2. Instead, `defaultValue` indicates the **original expression** which is specified by users.
+ *
+ * For example, if user create a table with (columnA, DATETIME, DEFAULT CURRENT_TIMESTAMP)
+ * `realDefaultValue` here is current date time while `defaultValue` is `CURRENT_TIMESTAMP`.
+ */
+ @SerializedName(value = "realDefaultValue")
+ private String realDefaultValue;
// Define expr may exist in two forms, one is analyzed, and the other is not analyzed.
// Currently, analyzed define expr is only used when creating materialized views,
// so the define expr in RollupJob must be analyzed.
@@ -134,12 +144,18 @@ public class Column implements Writable, GsonPostProcessable {
public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
String defaultValue, String comment) {
this(name, type, isKey, aggregateType, isAllowNull, defaultValue, comment, true, null,
- COLUMN_UNIQUE_ID_INIT_VALUE);
+ COLUMN_UNIQUE_ID_INIT_VALUE, defaultValue);
+ }
+
+ public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
+ String comment, boolean visible, int colUniqueId) {
+ this(name, type, isKey, aggregateType, isAllowNull, null, comment, visible, null,
+ colUniqueId, null);
}
public Column(String name, Type type, boolean isKey, AggregateType aggregateType, boolean isAllowNull,
String defaultValue, String comment, boolean visible, DefaultValueExprDef defaultValueExprDef,
- int colUniqueId) {
+ int colUniqueId, String realDefaultValue) {
this.name = name;
if (this.name == null) {
this.name = "";
@@ -155,6 +171,7 @@ public class Column implements Writable, GsonPostProcessable {
this.isKey = isKey;
this.isAllowNull = isAllowNull;
this.defaultValue = defaultValue;
+ this.realDefaultValue = realDefaultValue;
this.defaultValueExprDef = defaultValueExprDef;
this.comment = comment;
this.stats = new ColumnStats();
@@ -173,6 +190,7 @@ public class Column implements Writable, GsonPostProcessable {
this.isCompoundKey = column.isCompoundKey();
this.isAllowNull = column.isAllowNull();
this.defaultValue = column.getDefaultValue();
+ this.realDefaultValue = column.realDefaultValue;
this.defaultValueExprDef = column.defaultValueExprDef;
this.comment = column.getComment();
this.stats = column.getStats();
@@ -381,7 +399,8 @@ public class Column implements Writable, GsonPostProcessable {
}
tColumn.setIsKey(this.isKey);
tColumn.setIsAllowNull(this.isAllowNull);
- tColumn.setDefaultValue(this.defaultValue);
+ // keep compatibility
+ tColumn.setDefaultValue(this.realDefaultValue == null ? this.defaultValue : this.realDefaultValue);
tColumn.setVisible(visible);
toChildrenThrift(this, tColumn);
@@ -579,7 +598,8 @@ public class Column implements Writable, GsonPostProcessable {
@Override
public int hashCode() {
return Objects.hash(name, getDataType(), getStrLen(), getPrecision(), getScale(), aggregationType,
- isAggregationTypeImplicit, isKey, isAllowNull, defaultValue, comment, children, visible);
+ isAggregationTypeImplicit, isKey, isAllowNull, defaultValue, comment, children, visible,
+ realDefaultValue);
}
@Override
@@ -605,7 +625,8 @@ public class Column implements Writable, GsonPostProcessable {
&& getScale() == other.getScale()
&& Objects.equals(comment, other.comment)
&& visible == other.visible
- && Objects.equals(children, other.children);
+ && Objects.equals(children, other.children)
+ && Objects.equals(realDefaultValue, other.realDefaultValue);
}
@Override
@@ -628,6 +649,7 @@ public class Column implements Writable, GsonPostProcessable {
notNull = in.readBoolean();
if (notNull) {
defaultValue = Text.readString(in);
+ realDefaultValue = defaultValue;
}
stats = ColumnStats.read(in);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/HMSExternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/HMSExternalCatalog.java
index 336d31df7e..ccf05e597b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/HMSExternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/HMSExternalCatalog.java
@@ -192,7 +192,7 @@ public class HMSExternalCatalog extends ExternalCatalog {
for (FieldSchema field : schema) {
tmpSchema.add(new Column(field.getName(),
HiveMetaStoreClientHelper.hiveTypeToDorisType(field.getType()), true, null,
- true, null, field.getComment(), true, null, -1));
+ true, field.getComment(), true, -1));
}
return tmpSchema;
}
@@ -204,7 +204,7 @@ public class HMSExternalCatalog extends ExternalCatalog {
for (FieldSchema field : hmsSchema) {
tmpSchema.add(new Column(field.getName(),
HiveMetaStoreClientHelper.hiveTypeToDorisType(field.getType()), true, null,
- true, null, field.getComment(), true, null,
+ true, field.getComment(), true,
schema.caseInsensitiveFindField(field.getName()).fieldId()));
}
return tmpSchema;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
index 0f75b4755a..159359e462 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/external/jdbc/JdbcClient.java
@@ -678,8 +678,8 @@ public class JdbcClient {
for (JdbcFieldSchema field : jdbcTableSchema) {
dorisTableSchema.add(new Column(field.getColumnName(),
jdbcTypeToDoris(field), true, null,
- true, null, field.getRemarks(),
- true, null, -1));
+ true, field.getRemarks(),
+ true, -1));
}
return dorisTableSchema;
}
diff --git a/regression-test/data/datatype_p0/date/test_default_current_timestamp.out b/regression-test/data/datatype_p0/date/test_default_current_timestamp.out
new file mode 100644
index 0000000000..4ee136aef2
--- /dev/null
+++ b/regression-test/data/datatype_p0/date/test_default_current_timestamp.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql --
+2
+
diff --git a/regression-test/suites/datatype_p0/date/test_default_current_timestamp.groovy b/regression-test/suites/datatype_p0/date/test_default_current_timestamp.groovy
new file mode 100644
index 0000000000..1cc6ad8044
--- /dev/null
+++ b/regression-test/suites/datatype_p0/date/test_default_current_timestamp.groovy
@@ -0,0 +1,54 @@
+
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_default_current_timestamp") {
+ def tbName = "test_default_current_timestamp"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ sql """
+ CREATE TABLE IF NOT EXISTS ${tbName} (
+ `house_id` bigint(20) NULL DEFAULT "-1" COMMENT '仓库id',
+ `pick_order_big_num` decimal(27, 9) NULL
+ )
+ UNIQUE KEY(house_id)
+ DISTRIBUTED BY HASH(house_id) BUCKETS 5 properties("replication_num" = "1");
+ """
+ sql "insert into ${tbName} values(1,1.1)"
+ sql "insert into ${tbName} values(2,1.1)"
+
+ sql """ ALTER TABLE ${tbName} ADD COLUMN compute_time datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '计算时间' AFTER pick_order_big_num; """
+
+ def getJobState = { tableName ->
+ def jobStateResult = sql """ SHOW ALTER TABLE COLUMN WHERE IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+ return jobStateResult[0][9]
+ }
+ int max_try_time = 1000
+ while(max_try_time--){
+ String result = getJobState(tbName)
+ if (result == "FINISHED") {
+ break
+ } else {
+ sleep(100)
+ if (max_try_time < 1){
+ assertEquals(1,2)
+ }
+ }
+ }
+ sql """sync"""
+ qt_sql """ SELECT COUNT(*) FROM ${tbName} WHERE date(compute_time) = curdate() """
+ sql "DROP TABLE ${tbName}"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 10/15: [Bug](date) Fix BE crash caused by function `datediff` (#16397)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit bf58cc6fe13afbc4c21e3aaa3991d0531a7de288
Author: Gabriel <ga...@gmail.com>
AuthorDate: Sat Feb 4 18:43:23 2023 +0800
[Bug](date) Fix BE crash caused by function `datediff` (#16397)
* [Bug](date) Fix BE crash caused by function `datediff`
* update
---
be/src/vec/functions/function_date_or_datetime_computation.h | 4 +++-
.../query_p0/sql_functions/datetime_functions/test_date_function.out | 3 +++
.../sql_functions/datetime_functions/test_date_function.groovy | 1 +
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/functions/function_date_or_datetime_computation.h b/be/src/vec/functions/function_date_or_datetime_computation.h
index ee33e82cf7..b45333b89d 100644
--- a/be/src/vec/functions/function_date_or_datetime_computation.h
+++ b/be/src/vec/functions/function_date_or_datetime_computation.h
@@ -548,10 +548,12 @@ struct DateTimeAddIntervalImpl {
if (const auto* delta_vec_column = check_and_get_column<ColumnVector<FromType2>>(
*remove_nullable(block.get_by_position(arguments[1]).column))) {
Op::constant_vector(sources_const->template get_value<FromType1>(),
- col_to->get_data(), delta_vec_column->get_data());
+ col_to->get_data(), null_map->get_data(),
+ delta_vec_column->get_data());
} else {
Op::constant_vector(
sources_const->template get_value<FromType2>(), col_to->get_data(),
+ null_map->get_data(),
*remove_nullable(block.get_by_position(arguments[1]).column));
}
if (const auto* nullable_col = check_and_get_column<ColumnNullable>(
diff --git a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index 578da53634..57136bcf02 100644
--- a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++ b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -147,6 +147,9 @@
-- !sql --
16
+-- !sql --
+\N
+
-- !sql --
31
diff --git a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index e588c68569..f1220233c0 100644
--- a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++ b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -238,6 +238,7 @@ suite("test_date_function") {
qt_sql """ select datediff(CAST('2007-12-31 23:59:59' AS DATETIME), CAST('2007-12-30' AS DATETIME)) """
qt_sql """ select datediff(CAST('2010-11-30 23:59:59' AS DATETIME), CAST('2010-12-31' AS DATETIME)) """
qt_sql """ select datediff('2010-10-31', '2010-10-15') """
+ qt_sql """ select datediff('10000-10-31', '2010-10-15') from ${tableName}; """
// DAY
qt_sql """ select day('1987-01-31') """
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 13/15: [Enhancement](profile) lazy load profileContent string (#16354)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit deb35dbb3264da32c0a7ab925f631c599d6a98ab
Author: Xiangyu Wang <du...@gmail.com>
AuthorDate: Sat Feb 4 22:53:44 2023 +0800
[Enhancement](profile) lazy load profileContent string (#16354)
Sometimes the profileContent of ProfileElement is very large (more than 30MB), and this kind of huge string object may cause performance problems for gc. But we use them only when we invoke profile relevant restful apis (such as /profile/{format}/{query_id}, /api/profile and so on), so we need to lazy load them.
---
.../apache/doris/common/util/ProfileManager.java | 23 ++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
index c569d10c82..63a4cda0e9 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/ProfileManager.java
@@ -88,10 +88,26 @@ public class ProfileManager {
START_TIME, END_TIME, TOTAL_TIME, QUERY_STATE, TRACE_ID));
private class ProfileElement {
+ public ProfileElement(RuntimeProfile profile) {
+ this.profile = profile;
+ }
+
+ private final RuntimeProfile profile;
+ // cache the result of getProfileContent method
+ private volatile String profileContent;
public Map<String, String> infoStrings = Maps.newHashMap();
- public String profileContent = "";
public MultiProfileTreeBuilder builder = null;
public String errMsg = "";
+
+ // lazy load profileContent because sometimes profileContent is very large
+ public String getProfileContent() {
+ if (profileContent != null) {
+ return profileContent;
+ }
+ // no need to lock because the possibility of concurrent read is very low
+ profileContent = profile.toString();
+ return profileContent;
+ }
}
// only protect queryIdDeque; queryIdToProfileMap is concurrent, no need to protect
@@ -123,12 +139,11 @@ public class ProfileManager {
}
public ProfileElement createElement(RuntimeProfile profile) {
- ProfileElement element = new ProfileElement();
+ ProfileElement element = new ProfileElement(profile);
RuntimeProfile summaryProfile = profile.getChildList().get(0).first;
for (String header : PROFILE_HEADERS) {
element.infoStrings.put(header, summaryProfile.getInfoString(header));
}
- element.profileContent = profile.toString();
MultiProfileTreeBuilder builder = new MultiProfileTreeBuilder(profile);
try {
@@ -213,7 +228,7 @@ public class ProfileManager {
if (element == null) {
return null;
}
- return element.profileContent;
+ return element.getProfileContent();
} finally {
readLock.unlock();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 15/15: [fix](vertical compaction) fix uint32_t init value (#16377)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit acb7b675b487f54782aad8c89092b077c973c1d9
Author: yixiutt <10...@users.noreply.github.com>
AuthorDate: Sun Feb 5 00:05:35 2023 +0800
[fix](vertical compaction) fix uint32_t init value (#16377)
---
be/src/vec/olap/vertical_merge_iterator.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/be/src/vec/olap/vertical_merge_iterator.h b/be/src/vec/olap/vertical_merge_iterator.h
index 61cf723afc..0c6b66d8fc 100644
--- a/be/src/vec/olap/vertical_merge_iterator.h
+++ b/be/src/vec/olap/vertical_merge_iterator.h
@@ -184,14 +184,14 @@ private:
size_t _ori_return_cols = 0;
// segment order, used to compare key
- uint32_t _order = -1;
+ uint32_t _order = 0;
- uint32_t _seq_col_idx = -1;
+ int32_t _seq_col_idx = -1;
bool _valid = false;
bool _inited = false;
mutable bool _is_same = false;
- size_t _index_in_block = -1;
+ int32_t _index_in_block = -1;
size_t _block_row_max = 0;
int _num_key_columns;
size_t _cur_batch_num = 0;
@@ -320,4 +320,4 @@ std::shared_ptr<RowwiseIterator> new_vertical_mask_merge_iterator(
RowSourcesBuffer* row_sources_buf);
} // namespace vectorized
-} // namespace doris
\ No newline at end of file
+} // namespace doris
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 02/15: [bug](jdbc) fix jdbc insert decimalv3 be core dump (#16353)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit dc665d2d3516a15a9db8fb329bb00508837f6ae0
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Fri Feb 3 10:00:06 2023 +0800
[bug](jdbc) fix jdbc insert decimalv3 be core dump (#16353)
---
be/src/exec/table_connector.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/be/src/exec/table_connector.cpp b/be/src/exec/table_connector.cpp
index 6c310e4a60..c79cf4d63b 100644
--- a/be/src/exec/table_connector.cpp
+++ b/be/src/exec/table_connector.cpp
@@ -389,7 +389,8 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p
case TYPE_DECIMAL32:
case TYPE_DECIMAL64:
case TYPE_DECIMAL128I: {
- auto val = type_ptr->to_string(*column, row);
+ auto decimal_type = remove_nullable(type_ptr);
+ auto val = decimal_type->to_string(*column, row);
fmt::format_to(_insert_stmt_buffer, "{}", val);
break;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 07/15: [Bug](datev2) Fix bug when cast datev2 to date (#16394)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit d12a37044781c53b3e1edcf0e93d111cb1410ef9
Author: Gabriel <ga...@gmail.com>
AuthorDate: Fri Feb 3 20:50:16 2023 +0800
[Bug](datev2) Fix bug when cast datev2 to date (#16394)
---
be/src/vec/functions/function_cast.h | 9 +++--
.../data/datatype_p0/date/test_date_exprs.out | 7 ++++
.../suites/datatype_p0/date/test_date_exprs.groovy | 40 ++++++++++++++++++++++
3 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h
index a6817134ea..59f58be84c 100644
--- a/be/src/vec/functions/function_cast.h
+++ b/be/src/vec/functions/function_cast.h
@@ -194,17 +194,16 @@ struct ConvertImpl {
} else if constexpr (IsTimeType<ToDataType>) {
if constexpr (IsDateTimeType<ToDataType> && IsDateV2Type<FromDataType>) {
DataTypeDateV2::cast_to_date_time(vec_from[i], vec_to[i]);
- } else if constexpr (IsDateTimeV2Type<ToDataType> &&
- IsDateV2Type<FromDataType>) {
+ } else if constexpr (IsDateType<ToDataType> && IsDateV2Type<FromDataType>) {
DataTypeDateV2::cast_to_date(vec_from[i], vec_to[i]);
} else if constexpr (IsDateTimeType<ToDataType> &&
IsDateTimeV2Type<FromDataType>) {
DataTypeDateTimeV2::cast_to_date_time(vec_from[i], vec_to[i]);
- } else if constexpr (IsDateTimeV2Type<ToDataType> &&
+ } else if constexpr (IsDateType<ToDataType> &&
IsDateTimeV2Type<FromDataType>) {
DataTypeDateTimeV2::cast_to_date(vec_from[i], vec_to[i]);
- } else if constexpr (IsDateType<ToDataType> && IsDateV2Type<FromDataType>) {
- DataTypeDateV2::cast_to_date(vec_from[i], vec_to[i]);
+ } else {
+ return Status::InvalidArgument("Wrong cast expression!");
}
} else {
if constexpr (IsDateTimeV2Type<FromDataType>) {
diff --git a/regression-test/data/datatype_p0/date/test_date_exprs.out b/regression-test/data/datatype_p0/date/test_date_exprs.out
new file mode 100644
index 0000000000..35c3b94ede
--- /dev/null
+++ b/regression-test/data/datatype_p0/date/test_date_exprs.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !sql1 --
+2016-11-04
+
+-- !sql2 --
+2016-11-04
+
diff --git a/regression-test/suites/datatype_p0/date/test_date_exprs.groovy b/regression-test/suites/datatype_p0/date/test_date_exprs.groovy
new file mode 100644
index 0000000000..b77bb85bf5
--- /dev/null
+++ b/regression-test/suites/datatype_p0/date/test_date_exprs.groovy
@@ -0,0 +1,40 @@
+
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_date_exprs") {
+ def tbName = "test_date_exprs"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ sql """
+ create table ${tbName}(k1 datetimev2, k2 int) distributed by hash(k1) buckets 1 properties("replication_num" = "1");
+ """
+ sql """ insert into ${tbName} values("2016-11-04 00:00:01", 1); """
+
+ qt_sql1 """ select dt
+ from
+ (
+ select cast(k1 as datev2) as dt
+ from ${tbName}
+ ) r; """
+ qt_sql2 """ select dt
+ from
+ (
+ select cast(k1 as datev2) as dt
+ from ${tbName}
+ ) r; """
+ sql "DROP TABLE ${tbName}"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 09/15: [bugfix](disk balance) fix new rowset time check when add tablet (#16261)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 69e99daf30f8e82028998c9e4d20ebb637791433
Author: yixiutt <10...@users.noreply.github.com>
AuthorDate: Fri Feb 3 21:49:37 2023 +0800
[bugfix](disk balance) fix new rowset time check when add tablet (#16261)
In disk balancer, if a tablet is in highly concurrent load,
new rowset creation time(which use current time) may be same as the
newest rowset, and when add tablet, there has a creation time check
that new_time must bigger than old time, so disk balancer will failed
many times and makes this tablet lose many verisons as migration will
block writes.
---
be/src/olap/tablet_manager.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/be/src/olap/tablet_manager.cpp b/be/src/olap/tablet_manager.cpp
index 23c3e7c72c..9d111dd697 100644
--- a/be/src/olap/tablet_manager.cpp
+++ b/be/src/olap/tablet_manager.cpp
@@ -156,7 +156,7 @@ Status TabletManager::_add_tablet_unlocked(TTabletId tablet_id, const TabletShar
// here, the new rowset's file will also be dropped, so use keep files here
bool keep_files = force ? true : false;
if (force ||
- (new_version > old_version || (new_version == old_version && new_time > old_time))) {
+ (new_version > old_version || (new_version == old_version && new_time >= old_time))) {
// check if new tablet's meta is in store and add new tablet's meta to meta store
res = _add_tablet_to_map_unlocked(tablet_id, tablet, update_meta, keep_files,
true /*drop_old*/);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[doris] 01/15: [fix](scan) coredump caused by null of _scanner_ctx (#16361)
Posted by mo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 085fe7e4a9569b07fe5fadc309f32cd9834daa5b
Author: Jerry Hu <mr...@gmail.com>
AuthorDate: Fri Feb 3 09:24:15 2023 +0800
[fix](scan) coredump caused by null of _scanner_ctx (#16361)
---
be/src/vec/exec/scan/vscan_node.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exec/scan/vscan_node.cpp b/be/src/vec/exec/scan/vscan_node.cpp
index 57178d4d92..0d9c049cf7 100644
--- a/be/src/vec/exec/scan/vscan_node.cpp
+++ b/be/src/vec/exec/scan/vscan_node.cpp
@@ -109,8 +109,14 @@ Status VScanNode::get_next(RuntimeState* state, vectorized::Block* block, bool*
SCOPED_TIMER(_get_next_timer);
SCOPED_TIMER(_runtime_profile->total_time_counter());
if (state->is_cancelled()) {
- _scanner_ctx->set_status_on_error(Status::Cancelled("query cancelled"));
- return _scanner_ctx->status();
+ // ISSUE: https://github.com/apache/doris/issues/16360
+ // _scanner_ctx may be null here, see: `VScanNode::alloc_resource` (_eos == null)
+ if (_scanner_ctx) {
+ _scanner_ctx->set_status_on_error(Status::Cancelled("query cancelled"));
+ return _scanner_ctx->status();
+ } else {
+ return Status::Cancelled("query cancelled");
+ }
}
if (_eos) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org