For writing C++ std::strings as impala literals, we have to ensure that characters like single-quote are escaped properly. To do this, we escape every character into its octal equivalent: \PQR for some octal digits P, Q, and R. Currently, this only works for ASCII literals.
| 143 | // equivalent: \PQR for some octal digits P, Q, and R. Currently, this only works for |
| 144 | // ASCII literals. |
| 145 | string StringToOctalLiteral(const string& s) { |
| 146 | string result(4 * s.size(), 0); |
| 147 | for (int i = 0; i < s.size(); ++i) { |
| 148 | result[4 * i] = '\\'; |
| 149 | result[4 * i + 1] = '0' + (s[i] / 64); |
| 150 | result[4 * i + 2] = '0' + ((s[i] / 8) % 8); |
| 151 | result[4 * i + 3] = '0' + (s[i] % 8); |
| 152 | } |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | // Override the time zone for the duration of the scope. The time zone is overridden |
| 157 | // using an environment variable there is no risk of making a permanent system change |