## Fix COUNT(*) with NULL values**Problem:**COUNT(*) was incorrectly filtering NULL values, returning count of non-NULL rows instead of all rows.**Solution:**Updated COUNT(*) implementation to include NULL values in the count.**Testing:**- Added test case in `test/sql/aggregate/test_count_nulls.test`- Verified existing COUNT tests still pass- Tested with edge cases (all NULLs, no NULLs, mixed)Fixes #1234
// ✅ Prefer smart pointersauto table = make_unique<Table>();// ✅ Use unique_ptr by defaultunique_ptr<Operator> op;// ⚠️ Only use shared_ptr if absolutely necessaryshared_ptr<Resource> resource;// ❌ Avoid raw new/deleteTable *table = new Table(); // NO!
// ✅ Use range-based for loopsfor (const auto &item : items) { ProcessItem(item);}// ✅ Use override/final, not virtualvoid Execute() override; // Overriding virtual methodvoid Process() final; // Final override// ✅ Use braces for all control structuresif (condition) { DoSomething();}// ❌ Don't use single-line ifif (condition) DoSomething(); // NO!
class MyClass {public: // Constructor first MyClass(); // Public variables int my_public_variable;public: // Public methods void MyFunction();private: // Private methods void MyPrivateFunction();private: // Private variables int my_private_variable;};
// ✅ Use exceptions for query-terminating errorsif (!table_exists) { throw CatalogException("Table '%s' does not exist", name);}// ✅ Use return values for expected errorsbool TryParse(const string &input, Value &result) { if (!IsValid(input)) { return false; // Expected failure } result = Parse(input); return true;}
// ✅ Use D_ASSERT for internal invariantsD_ASSERT(index < vector_size); // Programmer error if falseD_ASSERT(!buffer.empty()); // Should never happen// ✅ Add comments explaining assertionsD_ASSERT(ptr != nullptr); // Buffer should have been allocated in Initialize()// ❌ Never assert on user inputD_ASSERT(age > 0); // NO! User can provide negative age
// ✅ Return early to reduce nestingvoid Process(Value &value) { if (!value.IsValid()) { return; } if (value.IsNull()) { return; } // Main logic here}// ❌ Deep nestingvoid Process(Value &value) { if (value.IsValid()) { if (!value.IsNull()) { // Main logic nested } }}
# test/sql/myfeature/basic.teststatement okCREATE TABLE test(i INTEGER);query ISELECT my_new_feature(i) FROM test;----expected_result
2
Test multiple data types
# Test with different typesquery ISELECT my_function(42);----resultquery R SELECT my_function(3.14);----resultquery TSELECT my_function('hello');----result
3
Test error conditions
statement error Division by zeroSELECT 1 / 0;statement error Column 'invalid' does not existSELECT invalid FROM test;
Do not submit AI-generated pull requests.Reviewing AI-generated code places a significant burden on maintainers. PRs identified as AI-generated will be closed.
Maintainers reserve final discretion on whether to merge a PR. Following these guidelines does not guarantee acceptance, but significantly increases the likelihood.