Assignment 3: Executor
Introduction
Welcome to the Executor assignment. This assignment exercises your understanding of an evaluator implementation for WHERE clauses.
In the Database Management Systems (DBMS), the ability to effectively query and manipulate data is foundational. A pivotal component of querying databases is the WHERE clause, which serves as a filter to select specific data that meets certain conditions. This assignment is designed to deepen your understanding of how DBMS evaluates these conditions, determining whether they are true or false for given data rows. By implementing an evaluator for the WHERE clause, you will gain hands-on experience in parsing and executing conditional logic.
Where Clause
The WHERE clause is a fundamental element of SQL queries that allows for the filtering of records, ensuring that only data satisfying specific conditions is selected, updated, or deleted from a database. It serves as a critical tool for data analysis and management, enabling precise control over the retrieval of information based on defined criteria.
A simplified WHERE clause can include various components:
●Column References: Direct references to the columns of a database table whose values are part of the conditions being evaluated.
●Constants: Fixed values against which column values are compared.
●Arithmetic Operations: Basic mathematical operations (addition, subtraction, multiplication, division) that can be performed on column values or constants within the condition.
●Logical Operators: Operators such as AND, OR, and NOT that are used to combine multiple conditions or negate a condition, respectively.
●Pattern Matching: Utilization of patterns (often with the LIKE operator) for matching string values according to a specified format.
●BETWEEN: A condition that checks if a column's value falls within a specified range.
●IN: A condition that checks if a column's value matches any value within a provided list.
●IS NULL and IS NOT NULL: Conditions that check for null (or missing) values.
●EXISTS: A logical operator that checks for the existence of rows in a subquery (though, for simplicity, subqueries won’t be considered in this assignment).
The WHERE clause is a powerful part of SQL that enhances the flexibility and effectiveness of database operations by allowing for complex and nuanced data querying strategies.
Assignment 3 Requirement
1.Understanding the Existing Code:
○Download the starter code at https://github.com/dbms-summer-2023/Command_Processor_Layer/tree/Assignment3.
○Familiarize yourself with the provided C++ starter code. Read the comments on the “testWhere.cpp” to understand how to test the Evaluator class.
○Analyze the structure of ParserTreeNode. It is necessary because you need to traverse an instance of ParseTreeNode when evaluating each node of the tree by your implementation of the Evaluator class.
2.Implement the Evaluate Function:
○Here is the signature of the method in the Evaluator class you need to implement. It is located in the folder /executor in the starter code.
bool evaluate(ParserTreeNode &node, std::unordered_map<std::string, std::string> &column_name_to_value);
○The provided parameters include a parsed tree, column names and its corresponding values. To simplify the process, column values are always provided as strings[In the production version of CapybaraDB, the method receives Storage Type instead of string.]. And the output is bool type, true or false. Your evaluator is expected to give a correct evaluation of the condition.
○Your implementation of evaluate() function in Evaluator class should cover the following:
i.Identify column names and find their values
ii.Comparison operators: =, >, <, >=, <=, <>
iii.Logical operators: AND, OR, NOT
iv.Range operators: BETWEEN ... AND …
v.List operators: IN (list)
○Your implementation of evaluate() function in Evaluator class DOES NOT need to cover the following:
i.Any built-in functions, such as UPPER(), GETDATE()
ii.Nullity checks: IS NULL, IS NOT NULL
iii.String operations: first_name || ' ' || last_name
iv.Arithmetic operation: +, -, *, /, %
v.Bitwise Operators: &, |, ^
vi.Pattern matching: LIKE
vii.Any subqueries or nested select statements: WHERE age IN (SELECT age from user_table)
viii.CASE WHEN THEN (ELSE) END
ix.ANY, ALL operators
x.Existence checks: EXISTS
3.Testing and Debugging:
○Take advantage of the 21 test cases provided under `Google_tests/testWhere.cpp` to test your implementation. You can also develop your own test cases.
○There are 27 hidden test cases on Autolab.
Output Examples
●Case 1
○Parsed tree node: WHERE age > 30;
○Values: {age: 31}
○Expected output: true
●Case 2
○Parse tree: WHERE age > 30 AND birth_year BETWEEN 2000 AND 2020;
○Values: {age: 31, birth_year: 1999}
○Expectedutput: false
Submission
In this assignment, you are expected to submit using Autolab. You should submit a "tar", which should contain the evaluator.cpp and evaluator.h.
How to Submit to Autolab:
1.Go to the website https://mvlander.dns.army/courses/18-671/assessments.
2.Use your Andrew email and your name to sign up.
3.Check your email for an activation message and use the access code YATHMX to activate your account.
4.Log in to your Autolab account.
5.Tar your evaluator.cpp and evaluator.h files using the command: tar -cvf <YourAndrewID>_Assignment3.tar evaluator.cpp evaluator.h.
6.Navigate to the assignment submission page.
7.Click on the "Submit" link for Assignment 3.
8.Choose your tarred file and upload it. And you will see the score and feedback
9.You are allowed only 10 attempts.
Rubric
Your assignment will be graded based on the following criteria:
●Correct implementation of the `evaluate` function;
●Number of Tests passed.
We strongly recommend starting your work locally and submit your Autolab "final version" as early as possible. Don't leave until the last moment to submit your assignment otherwise you may receive a penalty for late submission. This is because building the C++ project on Autolab can be time-consuming, and there is likely to be a high volume of users as the deadline approaches. You can also test your own test cases before attempting the autolab since everyone has only 10 chances.
Good luck and enjoy!
-
Zymeworks Announces FDA Clearance of Investigational New Drug Application for ZW171, a novel 2+1 T-cVANCOUVER, British Columbia, June 17, 2024 (GLOBE NEWSWIRE) -- Zymeworks Inc. (Nasdaq: ZYME), a clinical-stage biotechnology company developing a di2024-06-17
-
Indonesia Stock Exchange Partners with Nasdaq to Upgrade Market InfrastructureTechnology partnership will further enhance overall resilience and integrity of the exchange, while supporting the rapid deployment of new products2024-06-17
-
Adalvo 的 Liraglutide 預充式注射筆成為歐盟首款獲得批准的仿製藥馬爾他聖瓜安, June 17, 2024 (GLOBE NEWSWIRE) -- Adalvo 宣布 Liraglutide 預充式注射筆成功取得 DCP 批准,成為歐盟首款獲得批准的仿製藥。 根據 IQVIA 的報2024-06-17
-
促进生育,助力三胎——“三胎免费生”联合公益行动正式启动为积极响应国家号召实施三胎生育政策,扩大妇幼服务健康供给,在云南省优生优育妇幼保健协会指导下,昆明广播电视台联合昆明安琪儿妇产医院,于6月13日在昆明广播2024-06-17
-
学党史传承红色精神 守党纪筑牢自律防线——平安养老险湖南分公司党支部开展主题党日活动七一前夕,平安养老险湖南分公司党支部全体成员走进“千年学府、百年师范”——湖南第一师范,开展了一次学史明理、学史增信、学史崇德、学史力行的主题党日活动。重2024-06-17