Skip to content

Commit 4ed9bc5

Browse files
authored
Merge pull request #160 from microsoft/challenging-copilot
add GitHub Copilot with SQL, lesson 10
2 parents 822bd87 + 6c66754 commit 4ed9bc5

File tree

2 files changed

+184
-16
lines changed

2 files changed

+184
-16
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<h1 align="center">Challenging SQL with GitHub Copilot</h1>
2+
<h5 align="center">Push the limits of GitHub Copilot in complex workflows</h3>
3+
4+
<p align="center">
5+
<a href="#mega-prerequisites">Prerequisites</a> •
6+
<a href="#books-resources">Resources</a> •
7+
<a href="#learning-objectives">Learning Objectives</a>
8+
</p>
9+
10+
- **Who is this for**: Any tecnologist that is looking to advance basic techniques when working with GitHub Copilot. Software Engineers, Data Engineers, Data Scientists, and anyone working with challenging codebases or code projects.
11+
- **What you'll learn**: You'll use advanced GItHub Copilot techniques that are specifically useful when working with challenging problems. These techniques and patterns can be applied to difficult problems and when GitHub Copilot isn't providing the best answer.
12+
- **What you'll build**: A database with highly specific data with advanced queries that are unit tested for validation and correctness.
13+
14+
## Requirements
15+
16+
1. Enable your [GitHub Copilot service](https://github.com/github-copilot/signup)
17+
1. Open [this repository with Codespaces](https://codespaces.new/microsoft/challenging-github-copilot)
18+
19+
20+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/challenging-github-copilot)
21+
22+
## Learning Objectives
23+
24+
In this workshop, you will:
25+
26+
- Use advanced GitHub Copilot interaction techniques to deal with complex problems regarding SQL queries.
27+
- Iterate, validate, and refine answers to get better and more accurate suggestions
28+
- Apply generic concpets that can improve suggestions and select from different strategies that can yield better results.
29+
- Get a clear understanding on poor prompting techniques, and how these can
30+
affect drastically the output from GitHub Copilot.
31+
32+
## :mega: Prerequisites
33+
34+
Before joining the workshop, there is only one prerequisite: you must have a public GitHub account. All resources, dependencies, and data are part of the repository itself. Make sure you have your GitHub Copilot license, trial, or the free version.
35+
36+
37+
## Main takeaways
38+
39+
### 1. Define Clear Objectives and Requirements
40+
41+
*What needs to be achieved?*
42+
43+
Start by understanding the end goal clearly. What is the result you're after? In the case of SQL queries, is it about data aggregation, filtering, joining, etc.? Always ask: What do I need this query to accomplish?
44+
45+
*What are the constraints?*
46+
47+
Identify limitations or exclusions. For example, in the SQL query, you want to exclude specific batch types or data. In a broader sense, constraints might also include things like time restrictions, performance limits, or rules you need to follow.
48+
49+
> [!TIP]
50+
> Focus on being precise with the scope of the problem. If you're unsure, start broad and then progressively narrow down the details.
51+
52+
### 2. Break Down the Problem into Components
53+
54+
Decompose the problem into smaller, manageable pieces. For example, breaking down a complex SQL query:
55+
- Data filtering (e.g., today's data).
56+
- Data exclusions (e.g., "off-us" or "offset").
57+
- Aggregation (e.g., summing amounts).
58+
59+
Ensure you're applying each condition step-by-step. In programming, breaking down a complex function into smaller helper functions can make it easier to write and debug.
60+
61+
> [!TIP]
62+
> Decomposition is a great way to deal with complexity, as it allows you to focus on one small task at a time.
63+
64+
### 3. Leverage Domain-Specific Vocabulary and Context
65+
66+
Use the appropriate terminology for the problem domain. Whether you're writing SQL queries, working with code, or designing an algorithm, being familiar with the domain vocabulary helps you form more accurate instructions for tools like Copilot or while communicating with others.
67+
68+
69+
> [!TIP]
70+
> The more precise the vocabulary and context you use, the easier it is for both humans and tools to understand and generate solutions.
71+
72+
### 4. Iterate and Refine the Solution
73+
Start simple, then refine. In complex problems, initial attempts are rarely perfect. Start by generating a basic solution and progressively build on it.
74+
75+
In a SQL query, you might first write a query that selects all data for today, then add filters, exclusions, and aggregation in phases.
76+
77+
> [!TIP]
78+
> With every iteration, test and verify against expected outcomes to ensure the result is moving in the right direction.
79+
80+
### 5. Use Examples to Clarify Requirements
81+
When creating prompts for AI models or explaining problems, provide examples. An example can illustrate your expectations, making the task clearer for anyone or anything (including tools like GitHub Copilot) involved in solving the problem.
82+
83+
For instance, in SQL queries, you can use sample data and explain how the output should look.
84+
85+
> [!TIP]
86+
> Example-driven problem-solving helps align understanding. It's especially useful for ambiguous tasks.
87+
88+
### 6. Identify Patterns and Reuse Solutions
89+
Recognize common patterns in your problem and reuse solutions where applicable. For example, SQL queries often have common patterns (such as aggregation, filtering, or grouping), so once you identify them, you can reuse and modify these building blocks.
90+
91+
In code or other technical tasks, identifying reusable functions or logic can save time and reduce errors.
92+
93+
> [!TIP]
94+
> Recognizing patterns is a hallmark of experience. As you encounter similar problems repeatedly, you'll start to see similarities that can speed up your process.
95+
96+
### 7. Use Constraints and Edge Cases for Robustness
97+
Think about edge cases and exceptions. Complex problems often involve handling not just the "ideal" data, but also the "edge" or "outlier" cases that might break a naive solution. Ensure that your prompt or solution accounts for these edge cases.
98+
99+
In SQL, this could involve ensuring that empty datasets, null values, or unexpected data types don’t cause errors.
100+
101+
> [!TIP]
102+
> Thinking through edge cases helps you build more resilient, generalized solutions.
103+
104+
### 8. Use Tools Effectively
105+
Whether you’re using GitHub Copilot, a query builder, or another form of automation, leverage the tools at your disposal but make sure you're guiding them with the right context. Tools are great for speeding up the generation, but they still need well-structured inputs and validation from you.
106+
107+
For Copilot, ensure that your prompts are detailed, but concise. Tools often work best when given structured input that leaves little ambiguity.
108+
109+
> [!TIP]
110+
> Be specific with your tools, but also check results, as tools might not always fully understand context unless properly guided.
111+
112+
### 9. Seek Feedback and Collaboration
113+
When tackling a complex task, especially one that involves code or queries, collaboration and feedback are crucial. Don’t hesitate to ask peers or communities for insights or review.
114+
115+
For example, when creating a complex SQL query, someone else might see potential issues or better optimization strategies that you might have missed.
116+
117+
> [!TIP]
118+
> Collaboration often brings new perspectives, reducing blind spots.
119+
120+
### 10. Test and Validate
121+
Testing and validation are key to ensuring that your solution works as expected. In the case of SQL queries, you might test the query with various edge cases and compare it against expected outputs.
122+
123+
Testing ensures that both the expected and unexpected situations are handled correctly.
124+
125+
> [!TIP]
126+
> Always have a validation step built into your process to catch mistakes early.
127+
128+
Generalization for Other Use Cases:
129+
For writing code or algorithms: The same concepts apply when generating functions, classes, or workflows. Clearly define input, expected output, edge cases, and iterate to refine.
130+
131+
For AI model prompts: When asking for something complex (like generating code, text, or designs), give clear objectives, break down the problem, provide context, and iterate.
132+
133+
For design or content generation: Define the purpose, break down design elements, and provide examples or inspiration, then refine based on feedback.
134+
135+
Final Thoughts:
136+
Complex generation problems often involve a balance of clarity, decomposition, iteration, and validation. Whether it's a SQL query or any other task, keeping these concepts in mind will allow you to generate more accurate, efficient, and reliable results.
137+
138+
139+
140+
## :books: Resources
141+
142+
Although not required, some of the features this workshop covers are in these Microsoft Learning modules:
143+
144+
- [Code with GitHub Codespaces](https://learn.microsoft.com/training/modules/code-with-github-codespaces/)
145+
- [Using advanced GitHub Copilot features](https://learn.microsoft.com/training/modules/advanced-github-copilot/)
146+
147+
## Contributing
148+
149+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
150+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
151+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
152+
153+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
154+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
155+
provided by the bot. You will only need to do this once across all repos using our CLA.
156+
157+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
158+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
159+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
160+
161+
## Trademarks
162+
163+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
164+
trademarks or logos is subject to and must follow
165+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
166+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
167+
Any use of third-party trademarks or logos are subject to those third-party's policies.

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,52 @@ Unlock the power of collaborative coding with our comprehensive curriculum on Ma
77

88
## 🌱 Getting Started
99

10-
To get started, make sure to follow the instructions on how to fork the lessons into your own GitHub account. This will allow you to modify the code and complete the challenges at your own pace.
10+
To get started, make sure to follow the instructions on how to fork the lessons into your own GitHub account. This will allow you to modify the code and complete the challenges at your own pace.
1111

12-
To use GitHub Copilot, you must have an active GitHub Copilot subscription.
12+
To use GitHub Copilot, you must have an active GitHub Copilot subscription.
1313

14-
**Sign up for free here: [GitHub Copilot](https://gh.io/copilot).**
14+
**Sign up for free here: [GitHub Copilot](https://gh.io/copilot).**
1515

1616
To make it easier to revisit this repository in the future, you can also [star (🌟) this repo](https://docs.github.com/en/get-started/exploring-projects-on-github/saving-repositories-with-stars?WT.mc_id=academic-113596-abartolo) this repo.
1717

18-
Below are links to each lesson—feel free to explore and dive into any topic that interests you the most!
18+
Below are links to each lesson—feel free to explore and dive into any topic that interests you the most!
1919

2020

21-
## 🧠 Want to learn more?
22-
After completing this course, check out our [GitHub Copilot Learn Collection](https://learn.microsoft.com/collections/kkqrhmxoqn54?WT.mc_id=academic-113596-abartolo) to continue leveling up your AI Paired Programming knowledge!
21+
## 🧠 Want to learn more?
22+
After completing this course, check out our [GitHub Copilot Learn Collection](https://learn.microsoft.com/collections/kkqrhmxoqn54?WT.mc_id=academic-113596-abartolo) to continue leveling up your AI Paired Programming knowledge!
2323

24-
## 🚀 Are you a startup or got an idea you want to launch?
24+
## 🚀 Are you a startup or got an idea you want to launch?
2525

26-
Sign up for [Microsoft for Startups Founders Hub](https://foundershub.startups.microsoft.com/signup?WT.mc_id=academic-113596-abartolo) to receive **free OpenAI credits** and up to **$150k towards Azure credits to access OpenAI models through Azure OpenAI Services**.
26+
Sign up for [Microsoft for Startups Founders Hub](https://foundershub.startups.microsoft.com/signup?WT.mc_id=academic-113596-abartolo) to receive **free OpenAI credits** and up to **$150k towards Azure credits to access OpenAI models through Azure OpenAI Services**.
2727

2828
## 🙏 Want to help?
2929

30-
Here are ways you can contribute to this course:
30+
Here are ways you can contribute to this course:
3131
- Find spelling errors or code errors, [Raise an issue](https://github.com/microsoft/Mastering-GitHub-Copilot-for-Paired-Programming/issues/new/choose) or [Create a pull request](https://github.com/microsoft/Mastering-GitHub-Copilot-for-Paired-Programming/pulls)
3232
- Send us your ideas, maybe your ideas for new lessons or exercises, and let us know how we can improve.
3333

3434
## 📂 Each lesson includes:
3535

36-
- a written lesson located in the README
37-
- a challenge or assignment to apply your learning
36+
- a written lesson located in the README
37+
- a challenge or assignment to apply your learning
3838
- links to extra resources to continue your learning
3939

4040
## 🗃️ Lessons
41-
| | Lesson Link | Concepts Taught | Learning Goal |
41+
| | Lesson Link | Concepts Taught | Learning Goal |
4242
| :---: | :------------------------------------: | :---------------------------------------------------------: | ----------------------------------------------------------- |
4343
| 01 | [Introduction to GitHub](./01-Introduction-to-GitHub/README.md) | Get started using GitHub in less than an hour.| Introduction to repositories, branches, commits, and pull requests. |
44-
| 02 | [Introduction to GitHub Codespaces](./02-Introduction-to-GitHub-Codespaces) | Develop code using GitHub Codespaces and Visual Studio Code! | How to create a codespace, push code from a codespace, select a custom image, and customize a codespace. |
45-
| 03 | [Introduction to GitHub Copilot](./03-Introduction-to-GitHub-Copilot) | GitHub Copilot can help you code by offering autocomplete-style suggestions right in VS Code and Codespaces. | Creating files that will have code generated by Copilot AI for code and comment suggestions. |
44+
| 02 | [Introduction to GitHub Codespaces](./02-Introduction-to-GitHub-Codespaces) | Develop code using GitHub Codespaces and Visual Studio Code! | How to create a codespace, push code from a codespace, select a custom image, and customize a codespace. |
45+
| 03 | [Introduction to GitHub Copilot](./03-Introduction-to-GitHub-Copilot) | GitHub Copilot can help you code by offering autocomplete-style suggestions right in VS Code and Codespaces. | Creating files that will have code generated by Copilot AI for code and comment suggestions. |
4646
| 04 | [Using GitHub Copilot with JavaScript](./04-Using-GitHub-Copilot-with-JavaScript) | Use GitHub Copilot, an AI pair programmer that offers autocomplete-style suggestions as you code, to work with JavaScript. | Enable the GitHub Copilot extension in Visual Studio Code. Craft prompts that can generate useful suggestions from GitHub Copilot. Use GitHub Copilot to improve a JavaScript project. |
4747
| 05 | [Using GitHub Copilot with Python](./05-Using-GitHub-Copilot-with-Python) | Use GitHub Copilot, an AI pair programmer that offers autocomplete-style suggestions as you code, to work with Python. | Enable the GitHub Copilot extension in Visual Studio Code. Craft prompts that can generate useful suggestions from GitHub Copilot. Use GitHub Copilot to improve a Python project. |
4848
| 06 | [Using GitHub Copilot with C#](./06-Using-GitHub-Copilot-with-CSharp) | Use GitHub Copilot, an AI pair programmer that offers autocomplete-style suggestions as you code, to work with C#. | Enable the GitHub Copilot extension in Visual Studio Code. Craft prompts that can generate useful suggestions from GitHub Copilot. Use GitHub Copilot to improve a C# Minimal API project. |
4949
| 07 | [Creating a Mini Game with GitHub Copilot](./07-Creating-Mini-Game-with-GitHub-Copilot) | Use GitHub Copilot to assist you in building a Python based mini game. | Craft prompts that can generate useful suggestions from GitHub Copilot to incorporate gaming logic and improve your Python based game. |
5050
| 08 | [Using Advanced GitHub Copilot Features](./08-Using-Advanced-GitHub-Copilot-Features) | Use advanced GitHub Copilot features like inline chat, slash commands, and agents. | Interact with GitHub Copilot with deeper context on your project and ask questions about it. |
5151
| 09 | [**NEW** Getting Started with Copilot for Azure to Deploy to the Cloud](./09-Using-GitHub-Copilot-for-Azure-to-Deploy-to-Cloud) | Learn cloud deployment with GitHub Copilot for Azure—your ultimate guide to streamlined cloud success. | Effortless application deployment leveraging Azure’s powerful scalability. |
52+
| 10 | [**NEW** Challenging GitHub Copilot with complex SQL](./10-Challenging-GitHub-Copilot-with-SQL) | Apply advanced GitHub Copilot features to work with a challenging application working with a complex SQL query | Gain a clear understanding on how to work with extremely challenging SQL and yield better results when simple prompts don't work well |
5253

5354

54-
## 🎒 Other Courses
55+
## 🎒 Other Courses
5556

5657
Our team produces other courses! Check out:
5758

@@ -61,7 +62,7 @@ Our team produces other courses! Check out:
6162
- [AI for Beginners](https://aka.ms/ai-beginners)
6263
- [Data Science for Beginners](https://aka.ms/datascience-beginners)
6364
- [ML for Beginners](https://aka.ms/ml-beginners)
64-
- [Cybersecurity for Beginners](https://github.com/microsoft/Security-101)
65+
- [Cybersecurity for Beginners](https://github.com/microsoft/Security-101)
6566
- [Web Dev for Beginners](https://aka.ms/webdev-beginners)
6667
- [IoT for Beginners](https://aka.ms/iot-beginners)
6768
- [XR Development for Beginners](https://github.com/microsoft/xr-development-for-beginners)

0 commit comments

Comments
 (0)