<style>
.text-center {
text-align: center
}
h1{
border :none!important
}
</style>
<h1 class="text-center">
Assignment 3 Report 1
</h1>
<p class="text-center">110062143, 110062207, 110062208, 110062214</p>
## Implementation
### Lexer
- We add `explain` to the keyword list
### Parser
- We modify function `queryCommand()`. Using flag `isExplain` to check if there's an `explain` keyword in fornt of select command.
- Passing the flag "isExplain" as a parameter to the return value `QueryData `constructor.

### QueryData
- Adding a `isExplain` variable and initialzied with the passed in parameter `isExplain` in the constructor.
- A public function "isExplain()" is implemented, which return the private variable `isExplain`.
### AS3QueryPlanner
- Modify the properties QUERYPLANNER to AS3QueryPlanner

- Creating a `List<ExplainTreeNode>` to store the information of every plan is the plan tree.
- For example, we add a Node with planeType `TablePlan` and its information

- We've noticed that group by plan will call a sort plan by itself, so we will have to get the sort plan and add it to the `explainTree` when we have a group by plan.
- In the end, we create a ExplainPlan if the `isExplain` flag is true and pass the explainTree as a parameter to the ExplainPlan.

### ExplainPlan
- Add field "query-plan" to schema and store the `explainTree` in the constructor.
- pass the `explainTree` and the fields into a new `ExplainScan` in the function `open()`

### ExplainScan
- Add a variable `ans` to store the output and an `explainTree` variable.
- We call the function `getPlanTree()` to deal with the information in `explainTree`.
- A variable `visited` is created to make sure `next()` function will only be useful in the first call.
#### getPlanTree()
This function iterate through the List `explainTree` and add the infromation of the plan tree into variable `ans`.
#### getVal()
This function has a parameter fldName, is the fldName is in the field, that is, fldName == "query-plan", we will return the ans. Otherwise, we throw an exception.

### Plan
#### getDetails()
We've implement this function in `Plan` in order to get the details such as predicates and table info when storing the ans.
## Results
- A query accessing single table with `WHERE`

- A query accessing multiple tables with `WHERE`

- A query with `ORDER BY`

- A query with `GROUP BY` and at least one aggregation function (`MIN`, `MAX`, `COUNT`, `AVG`... etc.)
