TO_HEX() / FROM_HEX()
Basic Concepts Hexadecimal uses 16 symbols: 0-9 represent values 0-9, and A-F represent values 10-15. Two hex digits represent one byte (values 0-255). The letter "A" has ASCII value 65, which is 41 in hexadecimal (4*16 + 1 = 65). This direct byte-to-hex mapping makes hex ideal for inspecting exactly what bytes a string contains. Encoding & Decoding Each character becomes two hex digits. "Hello" is 5 characters, producing 10 hex digits. Reading the hex, 48 is "H", 65 is "e", and so on. This visibility into the actual bytes helps debug encoding issues. Decoding Hex to Text Best Practices Hex encoding reveals hidden characters and encoding problems that are invisible in normal display: The word "Cafe" with an accented e has 4 visible characters but 5 bytes because the accented e uses 2 bytes
About This Interactive Section
This section is part of the String Functions: Advanced lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live PostgreSQL database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.
How DataDriven Lessons Work
DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.